1.官網中文安裝參考手冊java
https://docs.docker-cn.com/engine/installation/linux/docker-ce/centos/#prerequisiteslinux
二、yum安裝gcc相關c++
1)CentOS7能上外網
docker
2)安裝gccjson
[root@localhost ~]# yum -y install gcc
3)安裝gcc-c++
ubuntu
[root@localhost ~]# yum -y install gcc-c++
vim
圖像出現以下說明安裝成功!!!centos
三、若是以前安裝過docker,卸載舊版本bash
[root@localhost ~]# yum remove docker \
> docker-client \
> docker-client-latest \
> docker-common \
> docker-latest \
> docker-latest-logrotate \
> docker-logrotate \
> docker-engine
四、安裝須要的軟件包app
[root@localhost ~]# yum install -y yum-utils device-mapper-persistent-data lvm2
五、設置stable鏡像倉庫
[root@localhost ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
六、更新yum軟件包索引
[root@localhost ~]# yum makecache fast
七、安裝DOCKER CE
[root@localhost ~]# yum -y install docker-ce
八、啓動docker
[root@localhost ~]# systemctl start docker
九、測試
1)查看docker版本
[root@localhost ~]# docker version
Client:
Version: 18.09.6
API version: 1.39
Go version: go1.10.8
Git commit: 481bc77156
Built: Sat May 4 02:34:58 2019
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 18.09.6
API version: 1.39 (minimum version 1.12)
Go version: go1.10.8
Git commit: 481bc77
Built: Sat May 4 02:02:43 2019
OS/Arch: linux/amd64
Experimental: false
[root@localhost ~]#
2)運行 hello-world
[root@localhost ~]# docker run hello-world
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/
[root@localhost ~]#
十一、配置鏡像加速
1)、獲取阿里雲鏡像加速器參考:https://blog.csdn.net/li1325169021/article/details/90770119
[root@localhost ~]# mkdir -p /etc/docker
[root@localhost ~]# vim /etc/docker/daemon.json
在文件中添加以下配置
#阿里雲鏡像加速器
#網易雲
{"registry-mirrors": ["http://hub-mirror.c.163.com"] }
#阿里雲
{
"registry-mirrors": ["https://{自已的編碼}.mirror.aliyuncs.com"]
}
[root@localhost ~]# systemctl daemon-reload
[root@localhost ~]# systemctl restart docker
2)、配置鏡像加速後重啓docker可能會報錯,參考:http://www.javashuo.com/article/p-yvwfjvaz-my.html
十二、卸載
[root@localhost ~]# systemctl stop docker [root@localhost ~]# yum -y remove docker-ce[root@localhost ~]# rm -rf /var/lib/docker