Docker创建容器后修改映射端口
跳到导航
跳到搜索
1、查看容器的信息
docker ps -a
2、查看容器的端口映射情况
docker port 容器ID docker port 容器名称
3、查找要修改容器的全ID
docker inspect 容器ID |grep Id
4、进入containers目录,找到与全 Id 相同的目录
- Linux
/var/lib/docker/containers 目录下
- Windows
\\wsl$\docker-desktop-data\data\docker\containers \\wsl.localhost\docker-desktop-data\data\docker\containers
5、停止容器
docker stop 容器ID
6、停止docker
systemctl stop docker
7、修改hostconfig.json
"PortBindings":{"22/tcp":[{"HostIp":"","HostPort":"3316"}],"80/tcp":[{"HostIp":"","HostPort":"180"}]}
8、修改config.v2.json在ExposedPorts中加上要暴露的端口
"ExposedPorts":{"22/tcp":{},"80/tcp":{}}