Docker Classroom Series – 26/Sep/2019

Some Questions to address

  • What is happening inside Docker Container?
  • What is happening inside Docker Image?
  • How to install Docker ?

Whats inside Docker Container ?

docker run -it tomcat:8 /bin/bash
  • execute the following commands
# This command shows the cpu & Memory info
ip addr
# This command shows the ip address & some network info
df -h
# This command will show all the mounts available
  • Every container gets cpu, RAM, storage,network and we also get OS
  • Execute the following command
java -version
# Now exit out of container 
# and then execute 
java -version
# Output will be java not found in Host OS & Found in container

What is Image and How to Create it

In Case of Non Docker


So what happens in Docker

  • It looks like same in the case of Docker as in above image Preview

What is Layer & when they will be created.

To understand lets start docker image creation

Docker Image Creation

  • To create Docker Image we will be using Dockerfile based Approach
  • Basics:
    • To create any Docker Image you have to choose the base image
    • In case of Linux DockerHub gives an image called as scratch
  • Create a Directory and inside Directory create a file called as Dockerfile
  • Inside Dockerfile add this one line
FROM tomcat:8
  • Lets build this image by executing following command
docker build -t myfirstdocker .
  • Lets Experiment
  • Execute myfirstdocker and see whether tomcat runs
docker run -d -p 8080:8080 myfirstdocker
  • Lets examine sizes
docker images
  • Lets build one more image by adding some thing more
FROM tomcat:8
RUN echo "hello" >> test.txt
  • Execute build comamnd
docker build -t myseconddocker .
  • Examine iamges by executing, you should see the new image id
docker images
  • Try to execute the following command to observer some layers are already downloaded
docker pull tomcat:9
  • We can now say layers are reused acrosss images

Install Docker

Refer Here

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About continuous learner

devops & cloud enthusiastic learner