From 63ff487c36818e3b7b6cc4dfec4c02938f8a8105 Mon Sep 17 00:00:00 2001 From: geminiyellow Date: Fri, 18 Mar 2016 13:08:12 +0900 Subject: [PATCH] docs(zh-cn): Add IP address example for cheat sheet 83e72cb6e9987cd5571fb2b71c0ed462b026bd22 --- zh-cn/README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/zh-cn/README.md b/zh-cn/README.md index 3e29095..effbf66 100644 --- a/zh-cn/README.md +++ b/zh-cn/README.md @@ -185,6 +185,19 @@ Docker 有[网络(networks)](https://docs.docker.com/engine/userguide/networking * [`docker network connect`](https://docs.docker.com/engine/reference/commandline/network_connect/) * [`docker network disconnect`](https://docs.docker.com/engine/reference/commandline/network_disconnect/) +你可以为[容器指定 IP 地址](https://blog.jessfraz.com/post/ips-for-all-the-things/): + +``` +# create a new bridge network with your subnet and gateway for your ip block +docker network create --subnet 203.0.113.0/24 --gateway 203.0.113.254 iptastic + +# run a nginx container with a specific ip in that block +$ docker run --rm -it --net iptastic --ip 203.0.113.2 nginx + +# curl the ip from any other place (assuming this is a public ip block duh) +$ curl 203.0.113.2 +``` + ## Registry 和 Repository 仓库(repository)是*被托管(hosted)*的已命名镜像(tagged images)集合,这组镜像用于构建容器文件系统。