sudo systemctl stop docker
修改/var/lib/docker/containers/[hash_of_the_container]/hostconfig.json
和/var/lib/docker/containers/[hash_of_the_container]/config.v2.json
"NetworkMode":"default",
"PortBindings":{
"10002/tcp":[{ // "10002/tcp" 容器端口
"HostIp":"",
"HostPort":"10002" // "10002" 宿主机端口
}],
....
}
这个文件要修改俩个地方 第一个地方
"Config":{
"Hostname":"f3d34c2e8a16",
"Domainname":"",
"User":"",
"AttachStdin":false,
"AttachStdout":false,
"AttachStderr":false,
-------------------------------
"ExposedPorts":{
"10002/tcp":{} //增加这部分内容,如果没有的话,这个地方是暴露的容器的端口
.....
},
--------------------------------
"Tty":true,
"OpenStdin":true,
"StdinOnce":false,
}
第二个地方
"Service":null,
"Ports":{
"10002/tcp":[{ //容器端口
"HostIp":"0.0.0.0",
"HostPort":"10002" //宿主机端口
}]
},
"SandboxKey":"/var/run/docker/netns/b30d214a0bf1"
sudo systemctl start docker
sudo systemctl stop docker
修改/var/lib/docker/containers/[hash_of_the_container]/config.v2.json
"MountPoints":{
"/root/workspace":{ //容器目录
"Source":"/home/nvidia/data/zhangbo", //宿主机目录
"Destination":"/root/workspace", //容器目录
"RW":true,
"Name":"",
"Driver":"",
"Type":"bind",
"Propagation":"rprivate",
"Spec":{
"Type":"bind",
"Source":"/home/nvidia/data/zhangbo", //宿主机目录
"Target":"/root/workspace" //容器目录
},
"SkipMountpointCreation":false
}
},
"SecretReferences":null, ...
sudo systemctl start docker