JiangMengYa 2020-04-11
查询需要修改端口映射的容器ID
docker inspect [OPTIONS] NAME|ID [NAME|ID...] OPTIONS说明 -f :指定返回值的模板文件。 -s :显示总的文件大小。 --type :为指定类型返回JSON。
cd ~/Library/Containers/com.docker.docker
cd /Data/vms/0 screen tty
cd /var/lib/docker/containerslscd a95ebce9c2e4b79374cdbbee81640b399fc5592411c83865bb8da583641b9c03 # 进入休要修改端口的容器文件夹
需要修改config.v2.json文件以及hostconfig.json两个文件
# 在ExposedPorts处添加需要映射的端口 "ExposedPorts": { "2200/tcp": {}, "8080/tcp": {}, "1000/tcp": {} },
截取片段 "Hostname": "a95ebce9c2e4", "Domainname": "", "User": "", "AttachStdin": true, "AttachStdout": true, "AttachStderr": true, "ExposedPorts": { "2200/tcp": {}, "8080/tcp": {}, "1000/tcp": {} },
#在PortBindings处添加端口映射地址 "PortBindings": { "2200/tcp": [ { "HostIp": "", "HostPort": "22" }], "8080/tcp": [ { "HostIp": "", "HostPort": "80" }], "1000/tcp": [ { "HostIp": "", "HostPort": "1000" }] },