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.
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:
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.
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.
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]
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.
The container does not commit, and the changes will be lost after restarting, unless the directory is mapped to a local file