пятница, 16 октября 2015 г.

Docker. Network settings

Docker network settings are the following:
--dns for setting up DNS server, which will be used by container.
-- dns-search. FQDN part without host name.

If --dns or --dns-search is not given, then the /etc/resolv.conf ile of the container will be the same as the /etc/resolv.conf file of the host the daemon is running on.

-h –hostname allows to setup the hostname of the container. The related record  will be added to the etc/hosts.

--link. Allows to setup the connection to other container. Knowledge IP of other container is not required. Only the name of the container.
To assign the name to the container one should use --name flag.

For example, there are two containers: web and db. To create the link between containers one should stop the web container and start it with --name flag like this:

 # docker run -d -P --name web --link db:db <image> startserver.sh
By using docker -ps you can see the links between containers.

Also in containers env variables and /etc/hosts are altered.

Also, container can bind the ports to the host ports. Use-p flag:
1. docker run -p IP:host_port:container_port
2. docker run -p IP::container_port
3. docker run -p host_port:container_port

When necessary containers can be moved to another subnet. For this the docker daemon should be used with —bip flag.

Комментариев нет:

Отправить комментарий