How to install Docker on CentOS 7 machine

Photo by Ian Taylor on Unsplash

How to install Docker on CentOS 7 machine

Overview:

  1. CentOS machine based on 7.9.2009(Core) release
  2. To check the version of the CentOS machine use:
    cat /etc/centos-release
    
  3. Docker community edition is installed

Docker installation and configuration:

  1. Remove the old version of the Docker from the machine:
    sudo yum remove -y docker \
    docker-client \
    docker-client-latest \
    docker-common \
    docker-latest \
    docker-latest-logrotate \
    docker-logrotate \
    docker-engine
    
  2. Install prerequisite utility software:
    sudo yum install -y yum-utils \
    device-mapper-persistent-data \
    lvm2
    
  3. Install the Docker repository:
    sudo yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo
    
  4. Install the Docker:
    sudo yum install -y docker-ce
    
  5. Start Docker daemon and enable autostartup:
    sudo systemctl start docker && sudo systemctl enable docker
    
  6. Add your current user to the docker group:
    sudo usermod -aG docker [username]
    
  7. For changes to take effect logout from your instance and then log back in
  8. Check the installed Docker version:
    docker version
    

Reference:

  1. yum-utils is a collection of tools and programs for managing yum repositories, installing debug packages, source packages, extended information from repositories and administration.
  2. device-mapper-persistent-data
  3. LVM2 refers to the userspace toolset that provide logical volume management facilities on linux. It is reasonably backwards-compatible with the original LVM toolset.