docker集装箱未能拉git回购

使用此引用安装泊坞窗。 我从我们的组织回购拉了一个基本的形象。 未能克隆私人回购。

我能够从terminal手动克隆这个回购,但不是从docker集装箱。 即使我试图用root用户运行docker命令,但没有运气。

$docker build -t foo . Step 1/10 : FROM my_private_org/base-service:v5-XYZ-ABC ---> 35a49840ec8b Step 2/10 : ENV PROJECT_NAME "project_name" ---> Using cache ---> 5dac344cb2fb Step 3/10 : RUN mkdir -p /code/$PROJECT_NAME ---> Using cache ---> 19c69074d66 Step 4/10 : WORKDIR /code/$PROJECT_NAME ---> Using cache ---> f5c8f4a549a5 Step 5/10 : ADD ./requirements.txt /code/$PROJECT_NAME/requirements.txt ---> Using cache ---> 93a42d0f46a8 Step 6/10 : RUN yes | pip3 install -r requirements.txt ---> Running in cad50cdbe473 Downloading/unpacking git+ssh://git@github.com/my_private_org/my_private_repo.git (from -r requirements.txt (line 12)) Cloning ssh://git@github.com/my_private_org/my_private_repo.git to /tmp/pip-w1w594tp-build ssh: Could not resolve hostname github.com: 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. Complete output from command /usr/bin/git clone -q ssh://git@github.com/my_private_org/my_private_repo.git /tmp/pip-w1w594tp-build: ---------------------------------------- Cleaning up.. 

更新了DockerFile

 FROM my_private_org/base-service:v5-XYZ-ABC # Set the project name ENV PROJECT_NAME="project_name" # Copy over the source RUN mkdir -p /workspace/$PROJECT_NAME WORKDIR /workspace/$PROJECT_NAME ADD ./requirements.txt /workspace/$PROJECT_NAME/requirements.txt #-- Its failing here # Install the requirements.txt RUN yes | pip3 install -r requirements.txt # ADD the app# ADD . /workspace/$PROJECT_NAME 

更新:

 $docker run --rm alpine:3.3 ping -c 3 github.com Unable to find image 'alpine:3.3' locally 3.3: Pulling from library/alpine 53ebc9bfbcc0: Downloading [=================> ] 814.8 kB/2.324 MB 

/etc/resolve.conf

 # Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8) # DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN nameserver 127.0.1.1 search example.com 

docker build启动一个容器并运行里面的东西,通常它会使用主机的同名服务器,但是容器内部的NMconfiguration似乎出了问题,使得它无法parsinggithub.com

无法parsing主机名github.com:名称或服务未知

但是--dns docker build没有选项--dns ,你可以尝试下面的方法:

  1. --dns选项启动--dns docker daemon ,这会影响包括容器在内的所有--dns操作。
  2. 按照这个解决方法为你的docker build设置/etc/resolv.conf

    • 在Dockerfile中,编辑/etc/resolv.conf来指向你的自定义DNS
    • 在需要这种自定义DNS的构build操作结束时,恢复正常的容器运行时resolv.conf

希望这可以帮助:-)