Home > Mobile >  docker how to disable resetting data after restart
docker how to disable resetting data after restart

Time:12-12

Im new in docker. I have wrote:

docker pull *docker from dockerhub*
docker run *image*
sudo apt-get install nano

And when i restart this image, nano is not installed Is it possible to turn off resetting data in docker container?

CodePudding user response:

The container filesystem is intrinsically temporary. If you docker run -d image twice, the two copies will each start from a fresh copy of the container filesystem and not share anything. There is no option to disable this.

Correspondingly, it is usually a mistake to install software in an interactive shell in a container, since that installation will be lost as soon as the container exits. It's usually unnecessary to install interactive editors like nano or vim, again since they can't make permanent changes. It's better to install your application and only the specific supporting programs it needs in a Dockerfile.

(There is a Docker command that can create a new image from a container, but this is pretty much never considered a best practice. It's hard to specify things like the command the resulting image should run, a chain of images made this way will grow over time, and it's all but impossible to take security updates from the original image. You may also run afoul of licensing or corporate source-tracking requirements with this approach.)

  • Related