您可以通过直接在以下位置编辑
hostconfig.json文件
来更改端口映射
/var/lib/docker/containers/[hash_of_the_container]/hostconfig.json
您可以通过
docker inspect <container_name>命令确定[hash_of_the_container] ,“
Id”字段的值为哈希。
1) stop the container 2) stop docker service (per Tacsiazuma's comment)3) change the file4) restart your docker engine (to flush/clear config caches)5) start the container
因此,您无需使用这种方法来创建图像。您也可以在此处更改重新启动标志。
PS:您可以访问
https://docs.docker.com/engine/admin/,以了解如何根据主机正确重新启动Docker引擎。我曾经sudosystemctl restart docker
重启过在Ubuntu 16.04上运行的Docker引擎



