一:在搭建好的虚拟机中配置好的Linux下安装:
注意:如果centos不是最新版,建议先更新到最新版后再来安装;
安装步骤:
使用yum安装
①:执行以下命令安装依赖包
[root@localhost /]# yum install -y yum-utils \
device-mapper-persistent-data \
lvm2
②:添加yum软件源(建议外网,)
[root@localhost /]#
yum-config-manager \ --add-repo \ https://mirrors.ustc.edu.cn/docker-ce/linux/centos/docker-ce.repo
安装Docker ce
③:更新yum软件源缓存,并安装docker-ce
[root@localhost /]# yum makecache fast
[root@localhost /]# yum install docker-ce
启动Docker CE
[root@localhost /]# systemctl enable docker
[root@localhost /]# systemctl start docker
注意:在这里启动的时候回报错,一直启动 不起来,在网上找了很多方案试过后并不行,后来更新了以下censtos之后,发现可以了,在这里适合自己,优秀的你也可以试一试!
测试Docker是否安装正确
[root@localhost /]# docker run hello-world
在这里会发现报错:
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
ca4f61b1923c: Pulling fs layer
docker: error pulling image configuration: Get https://dseasb33srnrn.cloudfront.net/registry-v2/docker/registry/v2/blobs/sha256/f2/f2a91732366c0332ccd7afd2a5c4ff2b9af81f549370f7a19acd460f87686bc7/data?Expires=1521641360&Signature=hldyqdMsLCFqvoEbCqB4Yfn67KvBD16Vt~Y7OBLGZavMql-foqxo1bsjc~eL81S5c3BJzWwSQLd8T1SPRyx00fjMFtm0tTds~Q68ccxIpbH6-OlkEPgdM5dk2uVbJLm8EzKv4Xq1Ti4nV113rwT~RL8U5MvLP4KG~mxnPZoeSvE_&Key-Pair-Id=APKAJECH5M7VWIS5YZ6Q: net/http: TLS handshake timeout.
解决方案:
[root@localhost ~]# cd /etc/docker/
[root@localhost docker]# ls
key.json (只有这个)
[root@localhost docker]# vi daemon.json(添加的)
在daemon.json添加信息:
配置镜像加速器:
{
"registry-mirrors": ["https://registry.docker-cn.com"]}
[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://cloud.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/engine/userguide/
表明镜像拉去成功!
1:[root@localhost ~]# yum install -y docker
检出是否安装成功
2:[root@localhost ~]# docker -v
这时候发现和主机ping不通了(xshell也连不上)
报错:Job for network.service failed because the control process exited with error code.。。 错误
解决:
3: [root@localhost ~]# systemctl stop NetworkManager
: [root@localhost ~]# systemctl disable NetworkManager
然后:重启网卡:
[root@localhost ~]# systemctl restart network
[root@localhost ~]# ifcongfig