1. Explain Docker Architecture
Before understanding architecture, lets understand how docker works in a simple way..
When you want to run a docker container, using command something like
docker run -d -p 8080:80 --name mynginx nginx
this actually tries to fetch nginx image that is not present in local, download nginx image from Docker Registry like Docker Hub and then runs container
what exactly happened here?. when command was run, it actually was run in docker client, which actually uses REST API´s to call Docker Daemon, and this docker daemon uses service called containerd, which runs the container either by pulling local image or from Docker Hub/Docker Registry
Here DockerDaemon manages core services like containers, volumes, images , networks and listens for API requests
And here REST API allows communication between server and client
containerd - manages lifecycle of container
2.What is Container Lifecycle?
lets understand container lifecyle by commands
docker create nginx
this command creates container with nginx image by pulling from docker hub or uses local image but does not run it
docker start <containerid>
this command runs the container
docker run nginx
this command brings the image and runs container, more like a combination of create and start
docker stop <containerid>
this command stops containers
docker rm <containerid>
this command deletes the container
docker pause <containerid>
this command pauses the process running inside container whereas docker stop command completely stops all the process running inside container
docker unpause <containerid>
it resumes the process that are needed
3. Explain Docker Networking and its various types
Docker networking helps containers to communicate with each other, with host, also with outside world
Different types of Network
1.Bridge
Its a default network which applies container IP to each container , you can say it mostly like private internal network
to expose to host, port mapping is required
2.host
docker run --network host nginx
this does not use seperate IP and uses same host IP directly, the container IP would be same as host IP
3.None
docker run --network none nginx
this has No IP address, No internet , like Nginx starts but other containers, neither localhost can access it
4.Overlay Network
this network is used when you have two different containers running in two different severs, and we need to establish communication between these two containers , thats when overlay network is used
5.Macvlan Network
Assigns a real MAC address to container, to behave like a complete seperate physical device
Comments
Post a Comment