Pass --net=host to docker build

2020-05-31 05:00发布

To pass other options to docker build, you can speciy DOCKER_OPTS in /etc/default/docker, however --net is not available. Is it possible to use the host's networking stack when building a container?

I'm running Docker version 1.3.2, build 39fa2fa.

Thanks!

标签: docker
3条回答
叛逆
2楼-- · 2020-05-31 05:21

From the newest versions (currently docker ce v17) it is possible to add --network=host to your docker build command which is similar to --net=host when using docker run!

查看更多
爷的心禁止访问
3楼-- · 2020-05-31 05:28

Try --network instead of --net. It is new in the 1.25 API and sets the networking mode for the RUN instructions.

查看更多
放我归山
4楼-- · 2020-05-31 05:39

To solve the problem, configure docker daemon to use the your company DNS server. For instance, if your resolv.conf has the following configuration:

$> cat /etc/resolv.conf
domain mycompany
search mycompany
nameserver 10.123.123.123

Change /etc/default/docker to contain the following:

DOCKER_OPTS="--dns 10.123.123.123"

And restart docker daemon with:

sudo service docker restart

Now, containers will have access to the intranet during the build operation.

Related answer: Dockerfile: Docker build can't download packages: centos->yum, debian/ubuntu->apt-get behind intranet

查看更多
登录 后发表回答