Table of contents:
- Basic Linux and Docker commands.
- [What is Docker?]
- [Docker Architecture.]
- [Docker vs Virtualization.]
- [Image vs Container.]
- [Docker Hub.]
- [Docker Daemon.]
- [Run Ubuntu OS on your local machine using container.]
- [Creating your own simple Image.]
Note: Before reading this blog i suggest you to be aware of basic LINUX commands. If you are not don't worry i got you..! make sure you are aware of the following basic Linux and Docker commands.
1. Basic Linux and Docker commands.
$docker images
- list all your images from your docker desktop.$docker pull <image_name>
- this command helps you to download images from the docker hub(if that image not present in your local machine)$docker ps
- list all the running containers.$docker ps -a
- list all the stopped containers.$docker container exec -it <#roothash_no> bash
- Attach the bash terminal with the running container.$docker logs <container_id>
- list all the activities that previously performed in the container.$docker <container_name> or <container_id>
- list all the implementation details of the particular image or container.$docker container prune -f
- delete all the stopped containers.$docker run -d <container_name>
- run a container in your machines background.
note:(-d) means detach i.e, background mode.
2. What is Docker?
Docker is a containerising tool of applications. It helps to easily build, deploy and test your applications. A developer defines all the applications and itβs dependencies in a Dockerfile which is then used to build Docker images that defines a Docker container. Doing this ensures that your application will run in any environment.
3.Docker Architecture
Docker uses a client-server architecture. The Docker client talks to the Docker daemon, which does the heavy lifting of building, running, and distributing your Docker containers.
4. Docker-Containerization vs Virtualization:
Now you may think "Wait..! docker-containerization does the same thing that virtual machines does, then why should i need to use docker instead of a virtual machine.?" well you are right to some point but it's not entirely true.
Let me tell you the difference.Observe the below diagram.
Now the main difference between the virtual machines and containers you may notice is the operating system. In a virtual machine we insert a virtualization layer( this is know as hypervisor in cloud) at the top of the host's operating system and top of this layer multiple VM's are created and run with different Guest OS. But in a docker a single OS and using a single Docker engine we can run multiple multiple conatiners with application.
5. Image vs Container.
Docker Image:
A Docker Image is a file that defines a Docker Container. It is similar in concept to a snapshot of a VM. A container that moves from one Docker environment to another with the same OS will work without changes because the image includes all of the dependencies needed to execute the code. Docker Image is run to create a docker container. Images are immutable. Once built, the files making up an image do not change.
Docker Conatiner:
A container is a runnable instance of an image. This is where your application is running. You can manage containers using the Docker API or CLI. You can connect a container to one or more networks, attach storage to it, or even create a new image based on its current state. If we delete a container the data will be lost! Because when the container went down and we brought it back up, the last layer got created again as a new layer. This helps in development if you donβt want to store record for each test.
6. Docker Hub:
Docker hub is like a App store or Play store in our mobiles. Docker hub contains all the images that you will ever need. It is a place where developers contribute their images, you can also publish your own image that you create.
7. Docker Daemon:
It listens to the API requests being made through the Docker client and manages Docker objects such as images, containers, networks, and volumes.
8. Run Ubuntu OS on your local machine using container
Top comments (0)