Before you install Docker Engine for the first time on a new host machine, you need to set up the Docker repository. Afterward, you can install and update Docker from the repository.
SET UP THE REPOSITORY
yum-utils package (which provides the
yum-config-manager utility) and set up the stable repository.
$ sudo yum install -y yum-utils $ sudo yum-config-manager \ --add-repo \ https://download.docker.com/linux/centos/docker-ce.repo
INSTALL DOCKER ENGINE
- Install the latest version of Docker Engine and containerd, or go to the next step to install a specific version:
$ sudo yum install docker-ce docker-ce-cli containerd.io
- Docker is installed but not started. The
dockergroup is created, but no users are added to the group.
- To install a specific version of Docker Engine, list the available versions in the repo, then select and install:a. List and sort the versions available in your repo. This example sorts results by version number, highest to lowest, and is truncated:
$ yum list docker-ce --showduplicates | sort -r
- Start Docker.
$ sudo systemctl start docker
- Verify that Docker Engine is installed correctly by running the
$ sudo docker run hello-world
also you can use this script for any OS