CentOS7.2
docker分为CE和EE版本,EE版本收费,一般我们使用CE版本就满足要求了
docker安装及启动
docker安装很简单,直接使用如下命令安装即可,安装后的docker版本即为CE免费版(对于更高的linux版本,可以先执行安装docker-ce,如果提示Nothing to do,则再直接使用如下命令)
yum -y install docker
安装结束后,查看docker运行状态
启动docker
查看/var/log/messages日志,扎到如下错误信息
Aug 12 19:29:14 localhost dockerd-current: 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 (--selinux-enabled=false)
根据错误提示,修改docker配置文件,设置--selinux-enabled=false
vim /etc/sysconfig/docker
保存后,重新启动docker,查看启动状态
设置docker开机启动
docker安装之后,已经安装了开机启动service文件,但还需要在设置下开机启动,才能在服务器重启时自动启动
systemctl enable docker
CentOS8
查询docker
系统版本为Basic Web Server
[root@localhost ~]# yum search docker Last metadata expiration check: 7:18:55 ago on Sun 13 Oct 2019 01:30:27 AM CST. ============================================================================== Summary & Name Matched: docker =============================================================================== podman-docker.noarch : Emulate Docker CLI using podman podman-docker.noarch : Emulate Docker CLI using podman pcp-pmda-docker.x86_64 : Performance Co-Pilot (PCP) metrics from the Docker daemon ================================================================================== Summary Matched: docker ================================================================================== oci-umount.x86_64 : OCI umount hook for docker oci-systemd-hook.x86_64 : OCI systemd hook for docker oci-systemd-hook.x86_64 : OCI systemd hook for docker skopeo.x86_64 : Inspect Docker images and repositories on registries
这里没有我们想要的docker-ce
下载docker-ce repo
curl https://download.docker.com/linux/centos/docker-ce.repo -o /etc/yum.repos.d/docker-ce.repo
安装docker
[root@localhost ~]# yum -y install docker-ce Docker CE Stable - x86_64 6.5 kB/s | 20 kB 00:03 Error: Problem: package docker-ce-3:19.03.3-3.el7.x86_64 requires containerd.io >= 1.2.2-3, but none of the providers can be installed - cannot install the best candidate for the job - package containerd.io-1.2.10-3.2.el7.x86_64 is excluded - package containerd.io-1.2.2-3.3.el7.x86_64 is excluded - package containerd.io-1.2.2-3.el7.x86_64 is excluded - package containerd.io-1.2.4-3.1.el7.x86_64 is excluded - package containerd.io-1.2.5-3.1.el7.x86_64 is excluded - package containerd.io-1.2.6-3.3.el7.x86_64 is excluded (try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)
提示信息中告诉我们需要containerd.io依赖
yum -y install https://download.docker.com/linux/fedora/30/x86_64/stable/Packages/containerd.io-1.2.6-3.3.fc30.x86_64.rpm
再次安装docker(如果在安装docker-ce repo之前执行过yum -y install docker,则需要先执行yum remove docker卸载)
yum -y install docker-ce
启动docker
systemctl start docker
加入开机启动
systemctl enable docker
systemctl daemon-reload
查看docker版本
[root@localhost ~]# docker version Client: Docker Engine - Community Version: 19.03.3 API version: 1.40 Go version: go1.12.10 Git commit: a872fc2f86 Built: Tue Oct 8 00:58:10 2019 OS/Arch: linux/amd64 Experimental: false Server: Docker Engine - Community Engine: Version: 19.03.3 API version: 1.40 (minimum version 1.12) Go version: go1.12.10 Git commit: a872fc2f86 Built: Tue Oct 8 00:56:46 2019 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.2.6 GitCommit: 894b81a4b802e4eb2a91d1ce216b8817763c29fb runc: Version: 1.0.0-rc8 GitCommit: 425e105d5a03fabd737a126ad93d62a9eeede87f docker-init: Version: 0.18.0 GitCommit: fec3683
到此docker就安装完成了