Home > Article > Operation and Maintenance > How to install docker ce
This article explains how to install Docker CE on CentOS.
1. Operating system requirements
To install Docker CE, you need the 64-bit version of CentOS 7.
2. Uninstall the old version
The earlier version of Docker is called docker or docker-engine. If these versions are installed, uninstall them and their associated dependencies.
$ sudo yum remove docker \ docker-common \ docker-selinux \ docker-engine
3. Set up the mirror warehouse
3.1. Install the required software packages. yum-utils provides the yum-config-manager utility, and the devicemapper storage driver requires device-mapper-persistent-data and lvm2.
$ sudo yum install -y yum-utils device-mapper-persistent-data lvm2
3.2. Use the following command to set up the stable image warehouse. You always need to use the stable repository, even if you also need to install the build through an edge or testing repository.
$ sudo yum-config-manager \ --add-repo \ https://download.docker.com/linux/centos/docker-ce.repo
3.3. Optional: Enable edge and testing mirror repositories. These repositories are included in the docker.repo file above, but are disabled by default. You can enable them together with the stable registry.
$ sudo yum-config-manager --enable docker-ce-edge $ sudo yum-config-manager --enable docker-ce-testing
3.4. You can disable the edge or testing mirror repository by running the yum-config-manager command with the –disable flag. To re-enable it, use the –enable flag. The following command is used to disable the edge registry.
$ sudo yum-config-manager --disable docker-ce-edge
4. Install Docker CE
4.1. yum software package index.
$ sudo yum makecache fast
4.2. Install the latest version of Docker CE, or go to the next step to install a specific version.
$ sudo yum install docker-ce
4.3. In a production system, you should install a specific version of Docker CE instead of always using the latest version. List available versions. This example uses the sort -r command to sort the results by version number (highest to lowest) and has been truncated.
$ yum list docker-ce.x86_64 --showduplicates | sort -r docker-ce.x86_64 17.06.0.el7 docker-ce-stable
The contents of this list depend on which registries are enabled, and will be specific to your CentOS version (in this example, represented by the .el7 suffix in the version). Choose a specific version to install. The second column is the version string. The third column is the name of the mirror warehouse, which indicates which mirror warehouse the software package comes from and is listed by its stability level.
To install a specific version, append the version string to the package name and separate them with a hyphen (-):
$ sudo yum install docker-ce-<VERSION>
4.4. Start Docker
$ sudo systemctl start docker
4.5. Verify that docker is installed correctly by running the hello-world image.
$ sudo docker run hello-world
Recommended related tutorials: docker tutorial
The above is the detailed content of How to install docker ce. For more information, please follow other related articles on the PHP Chinese website!