1、检查内核版本,必须是3.10及以上
uname -r
2、安装docker
yum install docker
3、输入y确认安装
4、启动docker
[root@localhost ~]# systemctl start 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查看原因:
[root@localhost ~]# systemctl status docker.service
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Tue 2020-04-07 23:31:15 EDT; 11min ago
Docs: http://docs.docker.com
Process: 5033 ExecStart=/usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdriver=systemd --userland-proxy-path=/usr/libexec/docker/docker-proxy-current --init-path=/usr/libexec/docker/docker-init-current --seccomp-profile=/etc/docker/seccomp.json $OPTIONS $DOCKER_STORAGE_OPTIONS $DOCKER_NETWORK_OPTIONS $ADD_REGISTRY $BLOCK_REGISTRY $INSECURE_REGISTRY $REGISTRIES (code=exited, status=1/FAILURE)
Main PID: 5033 (code=exited, status=1/FAILURE)
Apr 07 23:31:13 localhost.localdomain systemd[1]: Starting Docker Applicatio...
Apr 07 23:31:13 localhost.localdomain dockerd-current[5033]: time="2020-04-0...
Apr 07 23:31:13 localhost.localdomain dockerd-current[5033]: time="2020-04-0...
Apr 07 23:31:14 localhost.localdomain dockerd-current[5033]: time="2020-04-0...
Apr 07 23:31:15 localhost.localdomain dockerd-current[5033]: Error starting ...
Apr 07 23:31:15 localhost.localdomain systemd[1]: docker.service: main proce...
Apr 07 23:31:15 localhost.localdomain systemd[1]: Failed to start Docker App...
Apr 07 23:31:15 localhost.localdomain systemd[1]: Unit docker.service entere...
Apr 07 23:31:15 localhost.localdomain systemd[1]: docker.service failed.
Hint: Some lines were ellipsized, use -l to show in full.
解决方案:
# vi /etc/sysconfig/docker
然后出现:
# Modify these options if you want to change the way the docker daemon runs
OPTIONS='--selinux-enabled --log-driver=journald --signature-verification=false'
if [ -z "${DOCKER_CERT_PATH}" ]; then
DOCKER_CERT_PATH=/etc/docker
fi
# Do not add registries in this file anymore. Use /etc/containers/registries.conf
# instead. For more information reference the registries.conf(5) man page.
# Location used for temporary files, such as those created by
# docker load and build operations. Default is /var/lib/docker/tmp
# Can be overriden by setting the following environment variable.
# DOCKER_TMPDIR=/var/tmp
# Controls the /etc/cron.daily/docker-logrotate cron job status.
# To disable, uncomment the line below.
# LOGROTATE=false
# docker-latest daemon can be used by starting the docker-latest unitfile.
# To use docker-latest client, uncomment below lines
先将OPTIONS里的–selinux-enabled后面加上"=false",变成:
# Modify these options if you want to change the way the docker daemon runs
OPTIONS='--selinux-enabled=false --log-driver=journald --signature-verification=false'
if [ -z "${DOCKER_CERT_PATH}" ]; then
DOCKER_CERT_PATH=/etc/docker
fi
由于博主是刚刚接触这个,并不知道如何编辑,如何保存,退出,花了不少时间瞎弄。。。
按“A”键进入编辑,想要保存退出:先按Esc键,然后打出“:wq”,回车就行了。
重新启动:
# systemctl restart docker
5、开机启动docker
[root@localhost ~]# systemctl enable docker
6、停止docker
systemctl stop docker
问题解决了请点个赞,谢谢了。