Hi everyone! Earlier we have created docker container using nginx:alpine image and now we will learn to create snapshots of docker container. To the readers who have not read my previous article you can find it here. Don't forget to like it and share it😄
Let's create a container from nginx:alpine image and name it as "myweb" that will run on 80 port using Docker run command.
docker run -p 80:80 --name myweb -d nginx:alpine
We can now check our newly created container
docker ps -a
Docker exec command is used to execute a command in the running container.
docker exec -it myweb /bin/bash
It gives us an error, but why so??
Its because bash is not installed on our container so we are going to use /bin/sh.
Now let's add Tutorial.txt file in the root directory of our container.
press 'Ctrl + D' to exit
Now we have our container ready we can create snapshot of our container by using docker commit comand along with the container name/Id and new container name.
docker commit myweb mynginx
Let's check our newly created docker images.
And let's check if our file is there in image by creating a container from that image.
Our new container is created with name myweb_v2, now we will check for our Tutorial.txt file in a new container.
That's it for today, Happy Coding!.....