安装docker-ce
1、切换为root
用户
2、卸载旧版本(如果安装过旧版本的话)
yum remove -y docker\
docker-client\
docker-client-latest\
docker-common\
docker-latest\
docker-latest-logrotate\
docker-logrotate\
docker-selinux\
docker-engine-selinux\
docker-engine
3、安装需要的软件包
# yum-util 提供 yum-config-manager 功能
# 另外两个是 devicemapper 驱动依赖的
yum install -y yum-utils\
device-mapper-persistent-data\
lvm2
4、设置yum源\
由于官网的源太慢了,这里可以使用阿里云Docker Yum源替代:
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
sudo yum makecache fast
5、安装最新版本docker
yum install -y docker-ce
6、启动docker
systemctl start docker.service
7、设置开机自启动
systemctl enable docker.service
8、验证安装是否成功(有client和service两部分表示docker安装启动都成功了)
docker version
Client: Docker Engine - Community
Version: 19.03.5
API version: 1.40
Go version: go1.12.12
Git commit: 633a0ea
Built: Wed Nov 13 07:25:41 2019
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 19.03.5
API version: 1.40 (minimum version 1.12)
Go version: go1.12.12
Git commit: 633a0ea
Built: Wed Nov 13 07:24:18 2019
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.2.10
GitCommit: b34a5c8af56e510852c35414db4c1f4fa6172339
runc:
Version: 1.0.0-rc8+dev
GitCommit: 3e425f80a8c931f88e6d94a8c831b9d5aa481657
docker-init:
Version: 0.18.0
GitCommit: fec3683
安装docker-compose
github
的地址下载太慢了,国内可以使用http://get.daocloud.io/#install-compose网站上面的地址。
首先下载docker-compose
:
curl -L https://get.daocloud.io/docker/compose/releases/download/1.25.4/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
然后赋权限:
chmod +x /usr/local/bin/docker-compose
最后查看版本:
docker-compose -v