系统:centos7
docker组成:
(1)Docker Client客户端:Docker命令
(2)Docker Daemon守护进程,其实这就是一个Docker的服务
(3)Docker Image镜像模板:分层结构
(4)Docker Container容器,运行image镜像后就成了这个镜像的容器
linux上安装docker:
yum install docker
关闭防火墙
systemctl stop firewalld.service
systemctl disable firewalld.service 永久关闭防火墙
启动防docker
systemctl start docker
systemctl enable docker 开机自启
启动的时候报了一个错误
[root@localhost pluginconf.d]# 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.
这个意思是说docker服务的任务启动四百,因为一个错误码退出了进程。如果想查看详细原因执行systemctl status docker.service或者是journalctl -xe名就可以查看详细情况。
然后我们执行了systemctl status docker.service
[root@localhost pluginconf.d]# systemctl status docker.service
鈼[0m docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Sun 2021-07-11 15:46:59 CST; 19s ago
Docs: http://docs.docker.com
Process: 42109 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: 42109 (code=exited, status=1/FAILURE)
Jul 11 15:46:58 localhost.localdomain systemd[1]: Starting Docker Application Container Engine...
Jul 11 15:46:58 localhost.localdomain dockerd-current[42109]: time="2021-07-11T15:46:58.481602120+08:00" level=warning msg="could not change group /var/run/docker.sock to docker: group docker not found"
Jul 11 15:46:58 localhost.localdomain dockerd-current[42109]: time="2021-07-11T15:46:58.496327895+08:00" level=info msg="libcontainerd: new containerd process, pid: 42114"
Jul 11 15:46:59 localhost.localdomain dockerd-current[42109]: Error starting daemon: SELinux is not supported with the overlay2 graph driver on this kernel. Either boot into a newer kernel or disable selinux in docker (...-enabled=false)
Jul 11 15:46:59 localhost.localdomain systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
Jul 11 15:46:59 localhost.localdomain systemd[1]: Failed to start Docker Application Container Engine.
Jul 11 15:46:59 localhost.localdomain systemd[1]: Unit docker.service entered failed state.
Jul 11 15:46:59 localhost.localdomain systemd[1]: docker.service failed.
Hint: Some lines were ellipsized, use -l to show in full.
在这个日志中的一个关键信息是level=warning msg=“could not change group /var/run/docker.sock to docker: group docker not found”
用这段代码去网上一搜就能解决问题
在docker的配置文件/etc/sysconfig/docke 中设置禁用selinux。
然后执行systemctl start docker 就可正常启动了,随后docker的守护进程服务就启动了
随后我们使用docker version或者docker info就可以查看docker的版本号或者其他详细信息了