在CentOs7上安装Docker步骤如下:
首先我们要检查版本,因为在linux上安装Docker内核必须是3.0以上版本
uname -r
- 安装docker
yum install docker
- 安装过程当中有提示输入y回车继续
- 安装之后可以查看一下docker的版本
docker -v
- 启动docker命令
systemctl start docker
这里会报错,下面解决 - 设置docker开机自启
systemctl enable docker
- 重启docker
systemctl restart docker
- 停止docker
systemctl stop docker
在启动的时候报错:
Job for docker.service failed because the control process exited with error code . See "systemctl status docker.service" and "journalctl -xe" for details.
执行提示命令 systemctl status docker.service
内容如下:
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Mon 2019-05-20 13:13:33 EDT; 28s ago
Docs: http://docs.docker.com
Process: 5379 ExecStart=/usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/do cker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdriver=system d --userland-proxy-path=/usr/libexec/docker/docker-proxy-current --init-path=/usr/libexec/do cker/docker-init-current --seccomp-profile=/etc/docker/seccomp.json $OPTIONS $DOCKER_STORAGE _OPTIONS $DOCKER_NETWORK_OPTIONS $ADD_REGISTRY $BLOCK_REGISTRY $INSECURE_REGISTRY $REGISTRIE S (code=exited, status=1/FAILURE)
Main PID: 5379 (code=exited, status=1/FAILURE)
May 20 13:13:31 localhost.localdomain systemd[1]: Starting Docker Application Container.....
May 20 13:13:31 localhost.localdomain dockerd-current[5379]: time="2019-05-20T13:13:31.5..."
May 20 13:13:31 localhost.localdomain dockerd-current[5379]: time="2019-05-20T13:13:31.5..."
May 20 13:13:32 localhost.localdomain dockerd-current[5379]: time="2019-05-20T13:13:32.53...
May 20 13:13:33 localhost.localdomain dockerd-current[5379]: Error starting daemon: SELi...)
May 20 13:13:33 localhost.localdomain systemd[1]: docker.service: main process exited, ...RE
May 20 13:13:33 localhost.localdomain systemd[1]: Failed to start Docker Application Co...e.
May 20 13:13:33 localhost.localdomain systemd[1]: Unit docker.service entered failed state.
May 20 13:13:33 localhost.localdomain systemd[1]: docker.service failed.
Hint: Some lines were ellipsized, use -l to show in full.
解决办法:
打开docker的配置文件: vi /etc/sysconfig/docker
修改如下位置:
修改之后重启成功。