What is docker?
Docker is an open source software platform which is used to build, deploy and run applications by packaging into containers. These containers have all the binaries, libraries, dependencies, tools and runtime which are necessary for running those packaged applications.
These containers communicates with the kernel of host operating system to request and use the resources.
Docker Images:
The Docker images are template files which defines all the components and configuration details, which will be a part of running container. These images can either be downloaded from any public / private docker registry or we can create our own docker images using Dockerfile.
Docker Registry:
The docker registry is a repository for docker container images. A very famous registry is Docker Hub, from where we can pull or push the docker container images. Some organization use their own private registry for security and other reasons.
Dockerfile:
This is a very simple text file where you can specify the commands to build Docker images.
Install & Run Docker Container on CentOS
Step-1: Update the package manager database.
# yum check-update
Step-2: Installation of Prerequisite Packages.
# yum install -y yum-utils device-mapper-persistent-data lvm2
Step-3: Add the CentOS Repository for Docker
# yum-config-manager --add-repo download.docker.com/linux/centos/docker-ce...
Step-4: Docker Installation
# yum install docker
Step-5: Start Docker daemon
Now the docker daemon needs to be started. For this run the following command:
# systemctl start docker
Step-6: Configure Docker to Start Automatically
To make sure that docker starts every time when the server reboot, run the following command:
# systemctl enable docker
Step-7: Verify the Docker Status
To check the docker status, run the following command:
# systemctl status docker
Step-8: Pull the docker images
# docker pull hello-world
# docker pull centos
Step-9: See the downloaded Docker images
# docker images
Step-10: Run the docker container
# docker run -it hello-world
# docker run -it centos
Step-11: List the running docker containers
- To List all active containers
# docker ps
# docker ps -a
- To list the latest container you created
# docker ps -l
Step-12: Stop the container
# docker container stop blissful_leavitt