CentOS7和Ubuntu下安装Docker & Docker-Compose

2019-11-23 来源: starnight_cyber 发布在  https://www.cnblogs.com/Hi-blog/p/How-to-Install-Doker-and-Docker-Compose-on-CentOS-and-Ubuntu.html

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

CentOS篇

安装Docker

# cat /etc/redhat-release
CentOS Linux release  (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 , build 633a0ea
# docker version
Client: Docker Engine - Community
 Version:
 API version:       1.40
 Go version:        go1.12.12
 Git commit:        633a0ea
 Built:             Wed Nov  ::
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.12
  Git commit:       633a0ea
  Built:            Wed Nov  ::
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:
  GitCommit:        b34a5c8af56e510852c35414db4c1f4fa6172339
 runc:
  Version:          -rc8+dev
  GitCommit:        3e425f80a8c931f88e6d94a8c831b9d5aa481657
 docker-init:
  Version:
  GitCommit:        fec3683

安装Docker-Compose

  • 稳定版
# yum install -y epel-release
# yum install docker-compose -y   # 安装
# docker-compose -v
docker-compose version , 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 , build 0a186604

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

Ubuntu篇

安装Docker

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

安装Docker-Compose

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

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

相关文章