Dockerlab 103 Working with Docker image

Step 0 : Create docker hub account. https://hub.docker.com

Step 1 : Open Play with Docker or login in below with your docker hub account.

Step 2 : Click on start

Step 3 : It will start a 4 hr session, click on + ADD NEW INSTANCE

Step 4 : Click in terminal and press enter.

Step 5 : docker container run -it ubuntu bash

  • This command fetches image from docker registry, save it in your system and run container

  • option i is for interactive session and t is for terminal

Step 6 : apt-get update

apt-get install -y figlet

figlet "hello docker"

  • update repo and install figlet (it is a program that generates text banners)

  • figlet and these steps are just an example, you can install any program and modify steps as per your requirement

  • you will see big hello docker on screen

Step 7 : exit

  • type exit to come out of container

Step 8 : docker container ls -a

  • list all containers

Step 9 : docker container diff <container ID>

  • find difference between initial and updated container

  • use container id you found in step 8

Step 10 : docker container commit CONTAINER_ID

  • commit creates a new image locally

  • use container id you found in step 8

Step 11 : docker image ls

  • List local images

  • You will see a new image with no name and tag

Step 12 : docker image tag <IMAGE_ID> firstimage

  • use image id from step 11

  • In this step we are naming new image as firstimage

  • you can also add tags after image name as firstimage:1.0

Step 13 : docker image ls

  • list all images

  • new image has name firstimage and tag latest as no tag was provided

Step 14 : docker container run firstimage figlet hello

  • This will run container from image and use figlet to print big hello on screen