docker系列2-centos7下安装docker
1、卸载旧版本,没有安装过则跳过
$ sudo yum remove docker \ docker-client \ docker-client-latest \ docker-common \ docker-latest \ docker-latest-logrotate \ docker-logrotate \ docker-engine
2、从远程仓库安装
安装yum-utils工具包(包含了yum-config-manager工具)
$ sudo yum install -y yum-utils
安装stable仓库(必须安装)
$ sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
2.1、可选操作:
启用nightly、test仓库
$ sudo yum-config-manager --enable docker-ce-test $ sudo yum-config-manager --enable docker-ce-nightly
禁用用nightly仓库
$ sudo yum-config-manager --disable docker-ce-nightly
3、安装docker engine 默认安装最新版
$ sudo yum install docker-ce docker-ce-cli containerd.io
1)假如需要安装指定版本则,先查出可安装的版本列表,从高到低排列
$ yum list docker-ce --showduplicates | sort -r
2)指定版本安装
$ sudo yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io
4、启动docker
$ sudo systemctl start docker
5、查看安装版本
$ docker version
6、运行hello-world image 测试docker是否正确安装
$ sudo docker run hello-world
[root@bogon network-scripts]# sudo docker run hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world 0e03bdcc26d7: Already exists Digest: sha256:8e3114318a995a1ee497790535e7b88365222a21771ae7e53687ad76563e8e76 Status: Downloaded newer image for hello-world:latest Hello from Docker! This message shows that your installation appears to be working correctly. To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. (amd64) 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal. To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash Share images, automate workflows, and more with a free Docker ID: https://hub.docker.com/ For more examples and ideas, visit: https://docs.docker.com/get-started/
官方文档:https://docs.docker.com/engine/install/centos/
配置阿里云的镜像加速器