Is it “safe” to launch the container in docker?

As the title says, safe means ... the right way?

Safe = consistent, no data loss, professional, legal way.

We hope to share some impressions with pro docker users.

Q. Commit is safe to run docker containers (with the exception of real-time fast-paced materials and database material, your own comment is appreciated.)

Yes or No, the answer is accepted with a comment. Thank you

+5
docker
Dec 04 '14 at 7:01
source share
1 answer

All storage of memory and hard disk is stored inside the container instance. You should, as long as you do not use external volumes and servers (for example, external connected DBs), never get into a difficult position to stop / restart and send dockers. Please read on to delve deeper into this topic.

The question that you might want to ask yourself at the initial stage is how docker changes are saved to disk at runtime? What is really nice to check out is how docker really does it. The initial state of the container’s hard drive is what is given to it from the image. He may NOT write to this image. Instead of writing on the image, there is a difference in what has changed in the internal state of the containers compared to what is in the docker image. Docker uses the Union Filesystem technology, which creates a diff layer on top of the original state of the docker image.

This "diff" (designated as the recordable container in the image below) is stored in memory and disappears when you delete your container. However, when you use docker commit, a rewritable container that is stored in the temporary "state" of the container is saved inside the new image: I do not recommend this. The state of your new docker image is not represented in the docker file and cannot be easily restored from rebuilds. Creating a new docker file should not be difficult. So this is always the way for me personally.

When your docker works with mounted volumes, external servers / databases, you may want to make sure that you do not get synchronization and temporarily stop your services inside the docker container. When you use the dockerfile, you can run a script shell in your container to start connections, perform checks, and initialize the process to ensure reliable application creation. Again, launching the target container makes it difficult to do something like this.

Union filesystem

+4
Dec 04 '14 at 8:35
source share



All Articles