Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pass --net=host to docker build

Tags:

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!

like image 485
user2334289 Avatar asked Dec 12 '14 01:12

user2334289


People also ask

What is Docker build -- Network host?

Docker network host, also known as Docker host networking, is a networking mode in which a Docker container shares its network namespace with the host machine. The application inside the container can be accessed using a port at the host's IP address (e.g., port 80).

What network does Docker build use?

By default, docker uses the bridge network driver, which connects the containers to a network separate from the host.

Can you Dockerize .NET application?

You'll understand the Docker container build and deploy tasks for a . NET application. The Docker platform uses the Docker engine to quickly build and package apps as Docker images. These images are written in the Dockerfile format to be deployed and run in a layered container.

Can we assign IP to Docker container?

When you connect an existing container to a different network using docker network connect , you can use the --ip or --ip6 flags on that command to specify the container's IP address on the additional network. In the same way, a container's hostname defaults to be the container's ID in Docker.


2 Answers

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

like image 146
gukoff Avatar answered Sep 26 '22 21:09

gukoff


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

like image 22
Sergey Evstifeev Avatar answered Sep 24 '22 21:09

Sergey Evstifeev