美文网首页
Docker 安装指定版本与docker-compose

Docker 安装指定版本与docker-compose

作者: 一杉风雨 | 来源:发表于2018-10-03 16:04 被阅读0次

背景

有些项目会有docker版本的特定要求,这里记录下以ubuntu为例,如何安装指定版本的docker和docker-compose工具。

步骤

  1. 安装
# 清除系统中原有的docker
apt remove docker docker-engine docker.io
rm -rf /var/lib/docker/

# 安装依赖
apt install -y \
    apt-transport-https \
    ca-certificates \
    curl \
    software-properties-common

# 配置仓库
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
   
# 更新安装docker社区版
apt-get update
apt-get install -y docker-ce

# 查询支持版本,安装指定版本
apt-cache madison docker-ce
apt-get install -y docker-ce=17.09.1~ce-0~ubuntu
  1. 配置加速
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://i1el1i0w.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
  1. 安装docker-compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
  1. 使用docker命令时,需将用户修改为docker组成员。
adduser <username> <groupname>

相关文章

网友评论

      本文标题:Docker 安装指定版本与docker-compose

      本文链接:https://www.haomeiwen.com/subject/lonzoftx.html