How Docker Works
- Linux Container is used to isolate processes. This process isolation will contain all the code, dependencies, binaries and settings required to run the process.
- Docker containers when they started used to create linux containers. Linux releases where impacting docker containers, so they have written their own container creation library (runc)
- Refer Here for understanding docker internals
- Inside the container (process isolations), it has its own process tree and it has its own filesystem.
- CPU and memory are also allocated to the container
- This isolated process has its own ip address
- Container is getting whatever is needed to run the application. But How?
- Namespaces
- CGroups
- Process Isolation: Each container runs with its own kernel namespaces for the following
- Processes
- Networks
- Users
- Mount
- IPC
- UTS
Docker Image
- First Responsibility of DevOps Engineer: Containerize your applications. This means creating docker images for your applications.
- Docker image is collection of layers.
- Lets build a docker image for an application gameoflife
- Installation:
- tomcat with Java 8 installed
- copy the gameoflife.war file into webapps folder of tomcat
- To make this work we have taken an existing image with java and tomcat installed and copied our package into the folder and then application started working
- Doing this on running container is not sensible, it would be better if we can have some way of creating images.
- Steps:
- Take existing image
- Copy the necessary files/configurations
- Create an image with this.
- Installation:
- To Create images docker has Dockerfile , we will be using that from our next class. Refer Here for docker file reference.