问个问题啊, 我run 了一个container hello
,通过-p参数 映射主机端口 和 容器端口.
sudo docker run -d --name hello -p 8080:8080 -m 268435456 ubuntu:14.04 bin/bash -c "while true;do echo hello $(date); sleep 2; done"
然后通过 commit 命令生成新的镜像 sudo docker commit hello hello-image
.
在然后, 基于该镜像,使用docker run -d hello-image
重新运行一个新的容器(这个时候并没有指定-p参数).
新生成的容器 是没有 端口映射的,而且也没有之前容器设置的-m参数信息.
我的问题是: 如何理解新生成的容器没有映射端口和 内存限制这两项信息? 什么参数是属于容器的,什么参数是属于镜像的呢?
When the container is committed into a mirror, only the static files will be retained, because the container itself is also stopped at this time
You need to reserve the port, or use the dockerfile to open the port, and use the -P command when creating the container.
Or still run similar to the way you specified the port above. Otherwise, the port will not be opened, and everything related to the host must be dynamically specified when the container needs to be created.
sudo docker run -d --name hello -p 8080:8080 -m 268435456 ubuntu:14.04 bin/bash -c "while true;do echo hello $(date); sleep 2; done"
Port mapping belongs to the container and will not exist in the image. It must be specified every time it runs.