Docker System
Docker is a Containerization software. It is an application used to run various processes and softwares in a container. A Container is a package of various components and its dependencies in an isolated environment. For example, we can say Docker as an alternative method for Virtualization technology. As we all Know that virtualization technology can be used to run multiple OS in a single machine and thereby we can utilize the Resources of the machine. But Each OS installed in a virtual machine has its own Kernel. So Rather than Running Multiple Kernel for Multiple OS we can make use the kernel of the Host machine and Run multiple use OS in a single machine.
Advantages of Docker system
1. Docker containers use host system kernel so the resource utilization is very light.
2. Applications and there Dependencies are located inside a container which can be run in any docker host. So the docker system provides Portability.
Installing Docker
Prerequisites
1. One Centos 7 machine with root privileges.
2. Docker Repositories is present in the Centos 7 extra Repositories So no need to worry about it.
3. If the repo is not present, install it.
#yum install epel-release
#yum install docker-io
Install docker
# yum install docker
After installing Docker start the service and enable it.
#systemctl start docker
#systemctl enable docker
You can check the status of Docker service by
#systemctl status docker
=======> Status will show as active (running)
To verify everything is going in the right way run container test image
#docker run hello-world
======> You will get a message like “Hello from docker. This message shows that your installation appears to be working correctly”
Starting Docker Container
For starting Docker container we need to Download Docker image from Docker Hub. That is if u want to install a Ubuntu OS in your Docker we need to Download Ubuntu Image.
For downloading the image
#docker search Ubuntu
Based on your need you can choose which image needs to be downloaded locally and can download it locally.
#docker pull ubuntu
========> Ubuntu image will be downloaded and used
We can list all available docker images in our local host machine by using the command:
#docker images
You can remove a docker image from your Host machine by using the command:
# docker rmi
For example: docker rmi ubuntu
Now the image is all set in Our local host machine. If you run a command against this image You will get a running container. When the execution of the command end then you will have exited or non-running container. When you run another command against the same image you will get another container.
#docker run [local image] [command to run into the container]
Allocating a Name to Your Container
#docker run --name [container_name] [local image] [command to run into the container]
For example: docker run –name my_docker ubuntu cat /etc/debian_version
After allocating the name you can start, stop your container with this allotted name
#docker start [container_name]
#docker stop [container_name]
How to run a shell in Container?
#docker run -it ubuntu bash
-i
———–Used to start an interactive session
-t
———–allocate a tty and attaches stdin and stdout
ubuntu
—–Image which we used to create the container
/bin/bash
– Command part
For quit and return back to the host machine from running container session
use #exit
” margin_top=”50px” margin_bottom=”” animation_type=”slide” animation_direction=”left” animation_speed=”0.3″ class=”” id=””]
Leave A Comment
You must be logged in to post a comment.