![]() If this wasn't happening, each time you launched an image, a full copy of the filesystem would have to be made. Just before any write operation is performed in the running container, a copy of the file that would be modified is placed on the writeable layer of the container, and that is where the write operation takes place. To do this, changes between the image and the running container are tracked. This is a standard UNIX pattern that provides a single shared copy of some data, until the data is modified. Instead, it uses something called the copy-on-write mechanism. When we launch an image, the Docker engine does not make a full copy of the already stored image. After it has run, you can connect to localhost:8080 to verify that nginx responds.īut what's going on in the background, as far as this container's file system is concerned? To understand that, we need to look at the copy-on-write mechanism. This command maps port 80 of the container to port 8080 of the host machine. We can launch it like so: $ sudo docker run –name web1 -d -p 8080:80 nginx Now, if we want to launch an nginx container, the process is very fast because we already have the nginx image stored locally. Nginx latest 5328fdfe9b8e 5 months ago 133.9 MB You should see something like this: REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZEĪlpine latest 3e467a6273a3 3 weeks ago 4.797 MB We can verify this is the case by listing the local images: $ sudo docker images Once the command completes, you should have the nginx image in your local machine, being managed by your local Docker engine. On the Docker Hub, you can see the descriptions of Docker images and take a look at their Dockerfiles, which contain the instructions that tell Docker how to build the image from the source. When you run this command, Docker will attempt to pull the nginx image from the Docker Hub, which is a bit like GitHub but for Docker images. Let's imagine we want to pull a Docker image from a registry, like so: $ sudo docker pull nginx Check out the official docs for how to install Docker on Linux, or our previous post showing how to install Docker on a non-Linux machine. You will need Docker installed locally on your machine if you want to try out some of the commands in this post. In this post, I'll take a broad look at a few of them, including: image storage, the copy-on-write mechanism, union file systems, storage drivers, and volumes. There are lots of places inside Docker (both at the engine level and container level) that use or work with storage. With their kind permission, we are sharing it here for Codeship readers. ![]() This article was originally published on Deis by Eddy Mavungu. ![]()
0 Comments
Leave a Reply. |