Docker 安装
添加 Docker源
1 2 3 4 5 6 7 8
| sudo apt install apt-transport-https ca-certificates curl software-properties-common gnupg lsb-release
install -m 0755 -d /etc/apt/keyrings
sudo chmod a+r /etc/apt/keyrings/docker.gpg
|
添加 Docker 的官方 GPG
1 2 3
| curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
1 2 3 4 5
|
curl -fsSL https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
1 2 3 4
| # 添加阿里云官方GPG密钥 curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add - # 写入阿里云Docker仓库地址 sudo sh -c 'echo "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable" > /etc/apt/sources.list.d/docker.list'
|
更新 Ubuntu:
安装 Docker
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo apt install docker-ce=5:20.10.16~3-0~ubuntu-jammy docker-ce-cli=5:20.10.16~3-0~ubuntu-jammy containerd.io
sudo systemctl status docker
docker --version
sudo systemctl start docker sudo systemctl enable docker
|
1 2 3 4
| sudo newgrp docker sudo groupadd docker sudo usermod -aG docker ${USER} sudo systemctl restart docker
|
换源
2024年6月后,继续可以使用有效docker镜像仓库地址
1 2 3 4 5 6 7 8 9 10 11
| sudo mkdir -p /etc/docker sudo tee /etc/docker/daemon.json <<EOF { "registry-mirrors": ["https://dockerhub.icu"] } EOF
# 重启 docker sudo systemctl daemon-reload sudo systemctl restart docker sudo systemctl status docker
|
历史的镜像仓库地址:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| # 修改daemon.json文件, vim /etc/docker/daemon.json
# daemon.json内容如下: { "registry-mirrors": [ "https://dockerproxy.com", "https://docker.m.daocloud.io", "https://cr.console.aliyun.com", "https://ccr.ccs.tencentyun.com", "https://hub-mirror.c.163.com", "https://mirror.baidubce.com", "https://docker.nju.edu.cn", "https://docker.mirrors.sjtug.sjtu.edu.cn", "https://github.com/ustclug/mirrorrequest", "https://registry.docker-cn.com" ] }
# 重载配置文件,并重启 docker sudo systemctl daemon-reload sudo systemctl restart docker
# 查看 Registry Mirrors 配置是否成功 sudo docker info
|
安裝 Docker-composer
从Releases · docker/compose (github.com)下载最新 Docker Composer。
1 2 3 4 5
| sudo curl -L "https://mirror.ghproxy.com/https://github.com/docker/compose/releases/download/v2.18.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
|