centOs7安装docker以及docker compose

安装docker

docker官方说至少3.8以上,建议3.10以上

    1. root账户登录,查看内核版本如下

[root@localhost ~]# uname -a Linux localhost.qgc 3.10.0-862.11.6.el7.x86_64 #1 SMP Tue Aug 14 21:49:04 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

  • 卸载老版本

sudo yum remove docker \ docker-common \ docker-selinux \ docker-engine

    1. 安装需要的软件包, yum-util 提供yum-config-manager功能,另外两个是devicemapper驱动依赖的

yum install -y yum-utils device-mapper-persistent-data lvm2

    1. 设置yum源

yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

    1. 可以查看所有仓库中所有docker版本,并选择特定版本安装

yum list docker-ce --showduplicates | sort -r

    1. 安装Docker,命令:yum install docker-ce-版本号,我选的是17.12.1.ce,如下

yum install docker-ce 或者指定版本 yum install docker-ce-17.12.1.ce

    1. 启动Docker,命令:systemctl start docker,然后加入开机启动,如下

[root@localhost ~]# systemctl start docker [root@localhost ~]# systemctl enable docker Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.

    1. 验证安装是否成功(有client和service两部分表示docker安装启动都成功了)

[root@localhost ~]# docker version Client: Version: 17.12.1-ce API version: 1.35 Go version: go1.9.4 Git commit: 7390fc6 Built: Tue Feb 27 22:15:20 2018 OS/Arch: linux/amd64 Server: Engine: Version: 17.12.1-ce API version: 1.35 (minimum version 1.12) Go version: go1.9.4 Git commit: 7390fc6 Built: Tue Feb 27 22:17:54 2018 OS/Arch: linux/amd64 Experimental: false

安装docker-compose

安装docker-compose相对比较简单,可以直接去https://github.com/docker/compose/releases 查看文档安装

设置docker-compose可执行

sudo chmod +x /usr/local/bin/docker-compose

查看docker-compose是否安装成功

段落引用docker-compose --version