标签:docker 容器 docke ports setting json vdi ESS bsp 启动
但我觉得还是蛮通用的
docker run -d -p 80:80 --name name
$ docker stop A $ docker commit A imageA $ docker rm A $ docker run -d -p 80:80 --name A imageA
$ docker stop A $ systemctl stop docker
"PortBindings":{"容器端口/tcp":[{"HostIp":"","HostPort":"宿主机端口"}]
同时修改同目录下的 config.v2.json 中 "ExposedPorts":{"容器端口/tcp":{}}
"Ports":{"容器端口/tcp":[{"HostIp":"0.0.0.0","HostPort":"宿主机端口"}]}
$ systemctl start docker $ docker start A
例 hostconfig.json 已删除不相关配置,只保留格式
{ "Config": { "ExposedPorts": { "5700/tcp": {}, "6700/tcp": {}, "9000/tcp": {} } }, "NetworkSettings": { "Ports": { "5700/tcp": [{ "HostIp": "0.0.0.0", "HostPort": "10086" }], "6700/tcp": [{ "HostIp": "0.0.0.0", "HostPort": "6700" }], "9000/tcp": [{ "HostIp": "0.0.0.0", "HostPort": "8080" }] } } }
例 config.v2.json 已删除不相关配置,只保留格式
{ "PortBindings": { "5700/tcp": [{ "HostIp": "", "HostPort": "10086" }], "6700/tcp": [{ "HostIp": "", "HostPort": "6700" }], "9000/tcp": [{ "HostIp": "", "HostPort": "8080" }] } }
iptables -t nat -A DOCKER -p tcp --dport 宿主机端口 -j DNAT --to-destination 容器ip:容器端口
查看容器 ip
docker inspect --format=‘{{.NetworkSettings.IPAddress}}‘ $(docker ps -a -q)
更改 Docker 容器端口映射 (创建, 替换, 修改, 运行时)
标签:docker 容器 docke ports setting json vdi ESS bsp 启动
原文地址:https://www.cnblogs.com/zwjphp/p/13633565.html