[docker]docker网络类型network –network

来源:互联网 发布:淘宝100津贴是什么意思 编辑:程序博客网 时间:2024/06/05 21:06

参考:


http://note.youdao.com/noteshare?id=9cdb64028d5d5fb6b3e59f6562319864
https://www.ibm.com/developerworks/cn/linux/l-docker-network/index.html

Connect a container to a network (–network)

$ docker network lsNETWORK ID          NAME                DRIVER7fca4eb8c647        bridge              bridge9f904ee27bf5        none                nullcf03ee007fb4        host                host


When you start a container use the --network flag to connect it to a network. This adds the busybox container to the my-netnetwork.

$ docker run -itd --network=my-net busybox

You can also choose the IP addresses for the container with --ip and --ip6 flags when you start the container on a user-defined network.

$ docker run -itd --network=my-net --ip=10.10.9.75 busybox

If you want to add a running container to a network use the docker network connect subcommand.

You can connect multiple containers to the same network. Once connected, the containers can communicate easily need only another container’s IP address or name. For overlay networks or custom plugins that support multi-host connectivity, containers connected to the same multi-host network but launched from different Engines can also communicate in this way.

Note: Service discovery is unavailable on the default bridge network. Containers can communicate via their IP addresses by default. To communicate by name, they must be linked.

You can disconnect a container from a network using the docker network disconnect command.

参考https://docs.docker.com/engine/reference/commandline/run/#connect-a-container-to-a-network---network

0 0
原创粉丝点击