Some Questions to address
- What is happening inside Docker Container?
- What is happening inside Docker Image?
- How to install Docker ?
Whats inside Docker Container ?
- Lets navigate to Docker Playground
- Execute the following Command
docker run -it tomcat:8 /bin/bash
- execute the following commands
top # 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 exit # 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
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
- 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
- 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
- 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
- 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