02. Installing Docker Community Edition on CentOS
Overview
In this lesson, we explore the process of installing Docker Community Edition (CE) on a CentOS server. The article provides a step-by-step guide to setting up Docker CE in a CentOS environment, demonstrating its installation and configuration for practical use.
Installing Docker CE
- 
Installing Required Packages: Essential packages for Docker CE in CentOS, such as utils,device-mapper-persistent-data, andlvm2, are installed using the yum package manager.
$ sudo yum install -y yum-utils device-mapper-persistent-data lvm2
- 
Adding Docker Repository: The Docker CE repository is added using the yum-config-managertool to ensure access to Docker packages.
$ sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
- Docker Installation: Docker CE and its CLI (Command Line Interface) are installed with specific version numbers. Additionally, containerd.io is installed without specifying a version to get the latest one.
$ sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
- 
Starting Docker Service: The Docker service is started and enabled to run at boot using systemctlcommands. CentOS requires explicit configuration for services to start.
$ sudo systemctl enable --now docker.service
$ sudo systemctl status docker.service
Configuring Docker CE
- 
Verifying Installation: The installation's success is verified by running sudo docker version, confirming that both client and server details are returned.
- 
User Permissions: To allow non-root users (like ec2-user) to execute Docker commands, they are added to the docker group using usermod.
$ sudo  usermod -aG docker ec2-user
- Re-login for Group Changes: Users must log out and log back in for group changes to take effect.
$ docker version
Testing Docker Installation
- Running a Test Container: To ensure the Docker installation is functional, a simple hello-world container is run. This container prints a message to the console and exits, indicating that Docker can pull images and run containers successfully.
$ docker run hello-world
 

 
    
Top comments (0)