Skip to content

Latest commit

 

History

History

images_layers_hands_on

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

Basics of images and layers

Pulling basic nginx Image

docker pull saiakhil2012/nginx

See more details about basic nginx image

docker image inspect saiakhil2012/nginx

Pulling nginx with vim image

docker pull saiakhil2012/nginx:with_vim

See the more details about nginx with vim image

docker image inspect saiakhil2012/nginx:with_vim

Let us see the advantage of Layers of Images Practically

Run a container as shown below

docker run -d --name enhanced_nginx saiakhil2012/enhanced_nginx

Get into the container

docker exec -it enhanced_nginx /bin/bash

Create a file

cd /home/
vim myfile.txt
Hello World
:wq

Exit out of Container

exit

Create an Image out of the running the container

docker commit -m "Added myfile.txt" <container_id> saiakhil2012/nginx:with_vim_myfile

List out the images

docker images

Remove other related containers and start a container with the new image

docker run -d --name nginx_with_vim_myfile saiakhil2012/nginx:with_vim_myfile

Get into the container

docker exec -it enhanced_nginx /bin/bash

Check our file

cd /home/
vim myfile.txt
:q

Exit out of Container

exit

See more into these images

docker image inspect saiakhil2012/nginx:with_vim_myfile
docker image inspect saiakhil2012/nginx:with_vim

Check the history of image

docker image history saiakhil2012/nginx:with_vim
docker image history saiakhil2012/nginx:with_vim_myfile

Observe the comment which we added before