通过
docker run -it debian bash
进入的交互式镜像,结果每次的修改都没有自动保存。我记得是有这个功能的啊。。
就算不commit,进去的时候,做过的修改应该也保存了啊。。
debian 8
docker 1.10
伊谢尔伦2017-04-24 09:11:31
It’s not that it’s not saved, but every time you execute this command, a new container will be generated. You can view it through the command docker ps -l. You can re-enter the container through the docker attach container ID command and you will see that the original content still exists. of.
PHPz2017-04-24 09:11:31
All modifications made by docker in the container need to be committed before they can be saved to the image. If the things you want to modify in the container again are still there,
You can use docker run -idt to run the container and hang it in the background, or docker run -it after entering the container. Do not use exit to exit. Use control+p, control+q to let the container continue to run in the background.
docker run -idt debian bash
Then use docker attach or docker exec to enter the container to make modifications. It is recommended to use docker exec to enter. exec enters the container by opening another process, so exiting with exit will not affect the container to continue running in the background. The command is as follows:
docker exec -it [container id] bash
docker attach [container id]
PHP中文网2017-04-24 09:11:31
The above answers are all correct, but it is not recommended to use the attach command. It is recommended to use exec to enter the container to view changes. Because the exit of the attach command will cause the container to exit.
PHP中文网2017-04-24 09:11:31
The container does not commit, and the changes will be lost after restarting, unless the directory is mapped to a local file