欢迎来到starnight_cyber的博客

CentOS7和Ubuntu下安装Docker & Docker-Compose

  本篇介绍如何在CentOS 7.6和Ubuntu 16.04下安装Docker & Docker-Compose。

CentOS篇

安装Docker

# cat /etc/redhat-release 
CentOS Linux release 7.6.1810 (Core)
# yum remove docker docker-common docker-selinux                                            # 如之前安装,先卸载
# yum install -y yum-utils device-mapper-persistent-data lvm2                   # 安装依赖
# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo     # 配置软件包源
# yum install docker-ce -y                                        # 安装docker
# systemctl start docker                                         # 启动docker服务 
# systemctl enable docker                                         # 设置开机启动
# docker -v                                                 # 查看docker 版本
# docker info                                                # 查看docker详细信息
# docker -v
Docker version 19.03.5, build 633a0ea
# 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

  • 稳定版
# yum install -y epel-release
# yum install docker-compose -y   # 安装
# docker-compose -v
docker-compose version 1.18.0, build 8dd22a9
  • 最新版

  查看最新版本:https://github.com/docker/compose/releases/latest

# curl -L https://github.com/docker/compose/releases/download/1.25.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
# chmod +x /usr/local/bin/docker-compose
# mv /usr/local/bin/docker-compose /usr/bin/# docker-compose -v
docker-compose version 1.25.0, build 0a186604

  这样,当前最新版本就安装好了。

Ubuntu篇

安装Docker

# cat /etc/issue
Ubuntu 16.04.6 LTS \n \l
# apt update            # 更新
# apt install docker.io -y    # 安装docker
# docker -v            # 查看docker版本信息
Docker version 18.09.7, build 2d0083d

安装Docker-Compose

# apt install docker-compose -y
# docker-compose -v
docker-compose version 1.8.0, build unknown

  Ubuntu通过apt安装docker-compose,版本较老,如果要更新版本的docker-compose,请参考CentOS7.6安装Docker-Compose部分。

posted @ 2019-11-23 09:24  starnight_cyber  阅读(...)  评论(...编辑  收藏