公司代理后面的Docker Build“无法解析主机名”

时间:2019-02-13 09:57:24

标签: docker build proxy dns

我已经设置了适用于Windows的Docker,并带有GIT和Node.js。

尝试使用以下命令运行docker构建时

 $ docker build --no-cache -t hfc_joomla .

该错误在步骤7/12中可见,我在其中收到以下错误:

ssh:无法解析主机名bitbucket.org:名称或服务未知

致命:无法从远程存储库读取。

请确保您具有正确的访问权限 这是相应的完整控制台输出:

Sending build context to Docker daemon  9.728kB
Step 1/12 : FROM joomla:php7.0-apache
 ---> 81957e4d1db2
Step 2/12 : COPY --chown=root:root id_rsa* /root/.ssh/
 ---> 273debc28e33
Step 3/12 : RUN chmod 700 /root/.ssh && chmod 600 /root/.ssh/*
 ---> Running in cb2fb8a799fc
Removing intermediate container cb2fb8a799fc
 ---> 21ffb5c797e7
Step 4/12 : RUN apt-get -yq update && apt-get -yqq install ssh;     ssh-keyscan -H -t rsa bitbucket.org  >> /root/.ssh/known_hosts;     ssh-keyscan -H -t rsa hfc-ham.de >> /root/.ssh/known_hosts
 ---> Running in da941949c147
Get:1 http://security-cdn.debian.org/debian-security stretch/updates InRelease [94.3 kB]
Ign:2 http://cdn-fastly.deb.debian.org/debian stretch InRelease
Get:3 http://cdn-fastly.deb.debian.org/debian stretch-updates InRelease [91.0 kB]
Get:5 http://security-cdn.debian.org/debian-security stretch/updates/main amd64 Packages [475 kB]
Get:4 http://cdn-fastly.deb.debian.org/debian stretch Release [118 kB]
Get:6 http://cdn-fastly.deb.debian.org/debian stretch-updates/main amd64 Packages [7748 B]
Get:7 http://cdn-fastly.deb.debian.org/debian stretch Release.gpg [2434 B]
Get:8 http://cdn-fastly.deb.debian.org/debian stretch/main amd64 Packages [7090 kB]
Fetched 7878 kB in 8s (946 kB/s)
Reading package lists...
debconf: delaying package configuration, since apt-utils is not installed
(Reading database ... 13113 files and directories currently installed.)
Preparing to unpack .../libsystemd0_232-25+deb9u8_amd64.deb ...
Unpacking libsystemd0:amd64 (232-25+deb9u8) over (232-25+deb9u6) ...
Setting up libsystemd0:amd64 (232-25+deb9u8) ...
Selecting previously unselected package libapparmor1:amd64.
(Reading database ... 13113 files and directories currently installed.)
Preparing to unpack .../00-libapparmor1_2.11.0-3+deb9u2_amd64.deb ...
Unpacking libapparmor1:amd64 (2.11.0-3+deb9u2) ...
Selecting previously unselected package libcap2:amd64.
Preparing to unpack .../01-libcap2_1%3a2.25-1_amd64.deb ...
Unpacking libcap2:amd64 (1:2.25-1) ...
Selecting previously unselected package dmsetup.
Preparing to unpack .../02-dmsetup_2%3a1.02.137-2_amd64.deb ...
Unpacking dmsetup (2:1.02.137-2) ...
Selecting previously unselected package libdevmapper1.02.1:amd64.
Preparing to unpack .../03-libdevmapper1.02.1_2%3a1.02.137-2_amd64.deb ...
Unpacking libdevmapper1.02.1:amd64 (2:1.02.137-2) ...
Selecting previously unselected package libcryptsetup4:amd64.
Preparing to unpack .../04-libcryptsetup4_2%3a1.7.3-4_amd64.deb ...
Unpacking libcryptsetup4:amd64 (2:1.7.3-4) ...
Selecting previously unselected package libip4tc0:amd64.
Preparing to unpack .../05-libip4tc0_1.6.0+snapshot20161117-6_amd64.deb ...
Unpacking libip4tc0:amd64 (1.6.0+snapshot20161117-6) ...
Selecting previously unselected package libkmod2:amd64.
Preparing to unpack .../06-libkmod2_23-2_amd64.deb ...
Unpacking libkmod2:amd64 (23-2) ...
Selecting previously unselected package libseccomp2:amd64.
Preparing to unpack .../07-libseccomp2_2.3.1-2.1+deb9u1_amd64.deb ...
Unpacking libseccomp2:amd64 (2.3.1-2.1+deb9u1) ...
Selecting previously unselected package systemd.
Preparing to unpack .../08-systemd_232-25+deb9u8_amd64.deb ...
Unpacking systemd (232-25+deb9u8) ...
Selecting previously unselected package libxau6:amd64.
Preparing to unpack .../09-libxau6_1%3a1.0.8-1_amd64.deb ...
Unpacking libxau6:amd64 (1:1.0.8-1) ...
Selecting previously unselected package openssh-client.
Preparing to unpack .../10-openssh-client_1%3a7.4p1-10+deb9u5_amd64.deb ...
Unpacking openssh-client (1:7.4p1-10+deb9u5) ...
Selecting previously unselected package openssh-sftp-server.
Preparing to unpack .../11-openssh-sftp-server_1%3a7.4p1-10+deb9u5_amd64.deb ...
Unpacking openssh-sftp-server (1:7.4p1-10+deb9u5) ...
Selecting previously unselected package ucf.
Preparing to unpack .../12-ucf_3.0036_all.deb ...
Moving old data out of the way
Unpacking ucf (3.0036) ...
Selecting previously unselected package libwrap0:amd64.
Preparing to unpack .../13-libwrap0_7.6.q-26_amd64.deb ...
Unpacking libwrap0:amd64 (7.6.q-26) ...
Selecting previously unselected package openssh-server.
Preparing to unpack .../14-openssh-server_1%3a7.4p1-10+deb9u5_amd64.deb ...
Unpacking openssh-server (1:7.4p1-10+deb9u5) ...
Selecting previously unselected package ssh.
Preparing to unpack .../15-ssh_1%3a7.4p1-10+deb9u5_all.deb ...
Unpacking ssh (1:7.4p1-10+deb9u5) ...
Selecting previously unselected package libdbus-1-3:amd64.
Preparing to unpack .../16-libdbus-1-3_1.10.26-0+deb9u1_amd64.deb ...
Unpacking libdbus-1-3:amd64 (1.10.26-0+deb9u1) ...
Selecting previously unselected package dbus.
Preparing to unpack .../17-dbus_1.10.26-0+deb9u1_amd64.deb ...
Unpacking dbus (1.10.26-0+deb9u1) ...
Selecting previously unselected package ncurses-term.
Preparing to unpack .../18-ncurses-term_6.0+20161126-1+deb9u2_all.deb ...
Unpacking ncurses-term (6.0+20161126-1+deb9u2) ...
Selecting previously unselected package libnih1.
Preparing to unpack .../19-libnih1_1.0.3-8_amd64.deb ...
Unpacking libnih1 (1.0.3-8) ...
Selecting previously unselected package libnih-dbus1.
Preparing to unpack .../20-libnih-dbus1_1.0.3-8_amd64.deb ...
Unpacking libnih-dbus1 (1.0.3-8) ...
Selecting previously unselected package libcgmanager0:amd64.
Preparing to unpack .../21-libcgmanager0_0.41-2_amd64.deb ...
Unpacking libcgmanager0:amd64 (0.41-2) ...
Selecting previously unselected package cgmanager.
Preparing to unpack .../22-cgmanager_0.41-2_amd64.deb ...
Unpacking cgmanager (0.41-2) ...
Selecting previously unselected package systemd-shim.
Preparing to unpack .../23-systemd-shim_10-3_amd64.deb ...
Adding 'diversion of /usr/share/dbus-1/system-services/org.freedesktop.systemd1.service to /usr/share/dbus-1/system-services/org.freedesktop.systemd1.service.systemd by systemd-shim'
Unpacking systemd-shim (10-3) ...
Selecting previously unselected package libpam-systemd:amd64.
Preparing to unpack .../24-libpam-systemd_232-25+deb9u8_amd64.deb ...
Unpacking libpam-systemd:amd64 (232-25+deb9u8) ...
Selecting previously unselected package libxdmcp6:amd64.
Preparing to unpack .../25-libxdmcp6_1%3a1.1.2-3_amd64.deb ...
Unpacking libxdmcp6:amd64 (1:1.1.2-3) ...
Selecting previously unselected package libxcb1:amd64.
Preparing to unpack .../26-libxcb1_1.12-1_amd64.deb ...
Unpacking libxcb1:amd64 (1.12-1) ...
Selecting previously unselected package libx11-data.
Preparing to unpack .../27-libx11-data_2%3a1.6.4-3+deb9u1_all.deb ...
Unpacking libx11-data (2:1.6.4-3+deb9u1) ...
Selecting previously unselected package libx11-6:amd64.
Preparing to unpack .../28-libx11-6_2%3a1.6.4-3+deb9u1_amd64.deb ...
Unpacking libx11-6:amd64 (2:1.6.4-3+deb9u1) ...
Selecting previously unselected package libxext6:amd64.
Preparing to unpack .../29-libxext6_2%3a1.3.3-1+b2_amd64.deb ...
Unpacking libxext6:amd64 (2:1.3.3-1+b2) ...
Selecting previously unselected package libxmuu1:amd64.
Preparing to unpack .../30-libxmuu1_2%3a1.1.2-2_amd64.deb ...
Unpacking libxmuu1:amd64 (2:1.1.2-2) ...
Selecting previously unselected package tcpd.
Preparing to unpack .../31-tcpd_7.6.q-26_amd64.deb ...
Unpacking tcpd (7.6.q-26) ...
Selecting previously unselected package xauth.
Preparing to unpack .../32-xauth_1%3a1.0.9-1+b2_amd64.deb ...
Unpacking xauth (1:1.0.9-1+b2) ...
Setting up ncurses-term (6.0+20161126-1+deb9u2) ...
Setting up libip4tc0:amd64 (1.6.0+snapshot20161117-6) ...
Setting up libcap2:amd64 (1:2.25-1) ...
Setting up ucf (3.0036) ...
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
Setting up libkmod2:amd64 (23-2) ...
Processing triggers for libc-bin (2.24-11+deb9u3) ...
Setting up libseccomp2:amd64 (2.3.1-2.1+deb9u1) ...
Setting up libapparmor1:amd64 (2.11.0-3+deb9u2) ...
Setting up libxdmcp6:amd64 (1:1.1.2-3) ...
Setting up openssh-client (1:7.4p1-10+deb9u5) ...
Setting up libnih1 (1.0.3-8) ...
Setting up libx11-data (2:1.6.4-3+deb9u1) ...
Setting up libxau6:amd64 (1:1.0.8-1) ...
Setting up libdbus-1-3:amd64 (1.10.26-0+deb9u1) ...
Setting up libnih-dbus1 (1.0.3-8) ...
Setting up libwrap0:amd64 (7.6.q-26) ...
Setting up libcgmanager0:amd64 (0.41-2) ...
Setting up tcpd (7.6.q-26) ...
Setting up cgmanager (0.41-2) ...
Created symlink /etc/systemd/system/multi-user.target.wants/cgmanager.service → /lib/systemd/system/cgmanager.service.
Created symlink /etc/systemd/system/multi-user.target.wants/cgproxy.service → /lib/systemd/system/cgproxy.service.
invoke-rc.d: could not determine current runlevel
invoke-rc.d: policy-rc.d denied execution of start.
invoke-rc.d: could not determine current runlevel
invoke-rc.d: policy-rc.d denied execution of start.
Setting up openssh-sftp-server (1:7.4p1-10+deb9u5) ...
Setting up dbus (1.10.26-0+deb9u1) ...
invoke-rc.d: could not determine current runlevel
invoke-rc.d: policy-rc.d denied execution of start.
Setting up libxcb1:amd64 (1.12-1) ...
Setting up systemd-shim (10-3) ...
Setting up libx11-6:amd64 (2:1.6.4-3+deb9u1) ...
Setting up libxmuu1:amd64 (2:1.1.2-2) ...
Setting up openssh-server (1:7.4p1-10+deb9u5) ...
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline

Creating config file /etc/ssh/sshd_config with new version
Creating SSH2 RSA key; this may take some time ...
2048 SHA256:uqHbJJqVPYii2CPvd1/dkarOG+B9+BTutk2LqvjB4PQ root@da941923c147 (RSA)
Creating SSH2 ECDSA key; this may take some time ...
256 SHA256:0V4isICgSRVMDbcvzOtdqb6BjyiKF+wxkZJu/a4VswY root@da941923c147 (ECDSA)
Creating SSH2 ED25519 key; this may take some time ...
256 SHA256:VKTj5CfwI4aWUWHlWLX4JlSS3BvbP9Dsc52AABOig9Y root@da941923c147 (ED25519)
Created symlink /etc/systemd/system/sshd.service → /lib/systemd/system/ssh.service.
Created symlink /etc/systemd/system/multi-user.target.wants/ssh.service → /lib/systemd/system/ssh.service.
invoke-rc.d: could not determine current runlevel
invoke-rc.d: policy-rc.d denied execution of start.
Setting up libxext6:amd64 (2:1.3.3-1+b2) ...
Setting up xauth (1:1.0.9-1+b2) ...
Setting up ssh (1:7.4p1-10+deb9u5) ...
Setting up libdevmapper1.02.1:amd64 (2:1.02.137-2) ...
Setting up dmsetup (2:1.02.137-2) ...
Setting up libcryptsetup4:amd64 (2:1.7.3-4) ...
Setting up systemd (232-25+deb9u8) ...
Created symlink /etc/systemd/system/getty.target.wants/getty@tty1.service → /lib/systemd/system/getty@.service.
Created symlink /etc/systemd/system/multi-user.target.wants/remote-fs.target → /lib/systemd/system/remote-fs.target.
Created symlink /etc/systemd/system/sysinit.target.wants/systemd-timesyncd.service → /lib/systemd/system/systemd-timesyncd.service.
Adding group `systemd-journal' (GID 103) ...
Done.
Setting up libpam-systemd:amd64 (232-25+deb9u8) ...
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
Processing triggers for libc-bin (2.24-11+deb9u3) ...
Processing triggers for dbus (1.10.26-0+deb9u1) ...
getaddrinfo bitbucket.org: Name or service not known
getaddrinfo hfc-ham.de: Name or service not known
Removing intermediate container da941949c147
 ---> 471b5822cd46
Step 5/12 : RUN apt-get install -y --no-install-recommends git
 ---> Running in 49128bec92c5
Reading package lists...
Building dependency tree...
Reading state information...
The following additional packages will be installed:
  git-man libcurl3-gnutls liberror-perl
Suggested packages:
  gettext-base git-daemon-run | git-daemon-sysvinit git-doc git-el git-email
  git-gui gitk gitweb git-arch git-cvs git-mediawiki git-svn
Recommended packages:
  less rsync
The following NEW packages will be installed:
  git git-man libcurl3-gnutls liberror-perl
0 upgraded, 4 newly installed, 0 to remove and 13 not upgraded.
Need to get 5917 kB of archives.
After this operation, 31.8 MB of additional disk space will be used.
Get:1 http://cdn-fastly.deb.debian.org/debian stretch/main amd64 liberror-perl all 0.17024-1 [26.9 kB]
Get:2 http://cdn-fastly.deb.debian.org/debian stretch/main amd64 git-man all 1:2.11.0-3+deb9u4 [1433 kB]
Get:4 http://security-cdn.debian.org/debian-security stretch/updates/main amd64 libcurl3-gnutls amd64 7.52.1-5+deb9u9 [290 kB]
Get:3 http://cdn-fastly.deb.debian.org/debian stretch/main amd64 git amd64 1:2.11.0-3+deb9u4 [4167 kB]
debconf: delaying package configuration, since apt-utils is not installed
Fetched 5917 kB in 9s (633 kB/s)
Selecting previously unselected package libcurl3-gnutls:amd64.
(Reading database ... 17141 files and directories currently installed.)
Preparing to unpack .../libcurl3-gnutls_7.52.1-5+deb9u9_amd64.deb ...
Unpacking libcurl3-gnutls:amd64 (7.52.1-5+deb9u9) ...
Selecting previously unselected package liberror-perl.
Preparing to unpack .../liberror-perl_0.17024-1_all.deb ...
Unpacking liberror-perl (0.17024-1) ...
Selecting previously unselected package git-man.
Preparing to unpack .../git-man_1%3a2.11.0-3+deb9u4_all.deb ...
Unpacking git-man (1:2.11.0-3+deb9u4) ...
Selecting previously unselected package git.
Preparing to unpack .../git_1%3a2.11.0-3+deb9u4_amd64.deb ...
Unpacking git (1:2.11.0-3+deb9u4) ...
Setting up git-man (1:2.11.0-3+deb9u4) ...
Setting up liberror-perl (0.17024-1) ...
Setting up libcurl3-gnutls:amd64 (7.52.1-5+deb9u9) ...
Processing triggers for libc-bin (2.24-11+deb9u3) ...
Setting up git (1:2.11.0-3+deb9u4) ...
Removing intermediate container 49128bec92c5
 ---> 90103eb73762
Step 6/12 : WORKDIR /usr/src
 ---> Running in 3a34b59a24ce
Removing intermediate container 3a34b59a24ce
 ---> ea3e8ea82885
Step 7/12 : RUN rm -rf joomla ;     git clone git@bitbucket.org:hfc-ham/www-portal-hfc-ham.git joomla
 ---> Running in 2666b896680a
Cloning into 'joomla'...
ssh: Could not resolve hostname bitbucket.org: Name or service not known
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
The command '/bin/sh -c rm -rf joomla ;     git clone git@bitbucket.org:hfc-ham/www-portal-hfc-ham.git joomla' returned a non-zero code: 128

我正在公司代理后面运行系统,.docker /的config.json设置为以下内容(否则,步骤1-5将无法正常工作):

{
  "stackOrchestrator": "swarm",
  "proxies":
  {
   "default":
   {
     "httpProxy": "http://user:pw@prx-company.de:8080",
     "httpsProxy": "http://user:pw@prx-company.de:8080"
   }
  }
}

我确认仍然存在代理问题,或者可能是内部 Docker容器中的DNS问题,该容器无法连接到bitbucket,但我不知道如何解决此问题。

1 个答案:

答案 0 :(得分:0)

尝试像这样构建 docker 文件:

docker build --build-arg http_proxy=http://your.proxy:8080 --build-arg http_proxy=http://your.proxy:8080 -t yourimage  .