Reprinted from https://www.cnblogs.com/baolong/p/6526591.html
System Requirements
In order to install docker, you need to prepare 64-bit CentOS 7
Remove unofficial Docker packages
There is an old Docker package in the yum repository, and now Docker has officially renamed Docker to docker-engine. If you have installed this version of Docker, you need to use the following command to delete it
$ sudo yum -y remove docker docker-common container-selinux
/var/lib/docker
No need to delete.
Install Docker
There are two ways to provide installation to docker.
Use yum method
Set up Docker repository
- Use the command below to set up the latest stable version of the docker repository
$ sudo yum-config-manager \
--add-repo \
https://docs.docker.com/v1.13/engine/installation/linux/repo_files/centos/docker.repo
Install Docker
- update yum source
$ sudo yum makecache fast
- Install the latest version of docker
$ sudo yum -y install docker-engine
- Or install other versions of docker
$ yum list docker-engine.x86_64 --showduplicates |sort -r
docker-engine.x86_64 1.13.0-1.el7 docker-main
docker-engine.x86_64 1.12.5-1.el7 docker-main
docker-engine.x86_64 1.12.4-1.el7 docker-main
docker-engine.x86_64 1.12.3-1.el7 docker-main
$ sudo yum -y install docker-engine-<VERSION_STRING>
- start docker
$ sudo systemctl start docker
$ sudo systemctl enable docker
- To confirm that the docker installation is running properly install a demo image
$ sudo docker run hello-world
Upgrade Docker
$ sudo yum makecache fast
$ yum list docker-engine.x86_64 --showduplicates |sort -r
docker-engine.x86_64 1.13.0-1.el7 docker-main
docker-engine.x86_64 1.12.5-1.el7 docker-main
docker-engine.x86_64 1.12.4-1.el7 docker-main
docker-engine.x86_64 1.12.3-1.el7 docker-main
$ sudo yum -y install docker-engine-<VERSION_STRING>
rpm installation
-
Visit https://yum.dockerproject.org/repo/main/centos/ to select the corresponding docker version software according to the operating system version number.
-
Change to
path
the directory where docker.rpm is saved
$ sudo yum -y install /path/to/package.rpm
- start docker
$ sudo systemctl start docker
$ sudo systemctl enable docker
- To confirm that the docker installation is running properly install a demo image
$ sudo docker run hello-world
uninstall docker
- uninstall docker software
$ sudo yum -y remove docker-engine
- Images, containers, volumes, and configuration files will not be deleted automatically. You need to delete them manually. If you are sure you don't need them, you can execute the following commands:
$ sudo rm -rf /var/lib/docker
At the same time, various configuration files must be manually deleted
Reference documentation https://docs.docker.com/
Directory of system yum sources:
/etc/yum.repos.d