Docker安装教程

第一次安装docker,装了我两个小时,遇到了好多问题,分享一下

推荐一个大哥帖子

https://blog.csdn.net/laughing1997/article/details/84305615
我主要的步骤都是根据他的步骤来的。

一、安装工具包

sudo yum install -y yum-utils 

二、设置远程仓库

yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

原作者放的镜像很慢,这里我推荐把镜像换成阿里的。

三、安装

sudo yum install docker-ce

之后一路y,直到Complete! 为止。

四、启动

启动docker:systemctl start docker

停止docker:systemctl stop docker

重启docker:systemctl restart docker

查看docker状态:systemctl status docker

开机启动:systemctl enable docker

测试

sudo 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/

只要在前几行看到了Hello from Docker!那你就成功了!

安装中遇到的问题

一、docker: Error response from daemon: … : net/http: TLS handshake timeout.
这是由docker仓库使用的不是国内的镜像源、所以你要换成国内的。
https://blog.csdn.net/jixuju/article/details/80158493
上面的链接里有几个镜像源,我使用的是阿里巴巴的。
修改方法:

# vi /etc/docker/daemon.json

{
	"registry-mirrors": ["https://pee6w651.mirror.aliyuncs.com"]
}

二、由这个配置可能会引发一个小小的问题
Job for docker.service failed because the control process exited with error code. See
我百度了一下,出现这个问题的原因有很多,我这里是因为自己的daemon.json编写的格式不正确所引发,忘了加大括号。
三、当启动时遇到 Redirecting to /bin/systemctl start docker.service 问题
可能有的博主给的命令诸如:

sudo service docker start

service docker start  

我这边是没有什么作用的,似乎必须要systemctl的命令前缀才能识别。

End

Author By 朝花不迟暮

Docker安装教程_第1张图片

你可能感兴趣的:(Docker,docker)