赞
踩
国内安装指南: https://mirrors.tuna.tsinghua.edu.cn/help/docker-ce/
# 如果你过去安装过 docker, 先删掉:
sudo apt-get remove docker docker-engine docker.io
# 首先安装依赖:
sudo apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common
# 信任 Docker 的 GPG 公钥:
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
# 对于 amd64 架构的计算机, 添加软件仓库:
sudo add-apt-repository \
"deb [arch=amd64] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/debian \
$(lsb_release -cs) \
stable"
# 如果你是树莓派或其它 ARM 架构计算机, 请运行:
echo "deb [arch=armhf] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/debian \
$(lsb_release -cs) stable" | \
sudo tee /etc/apt/sources.list.d/docker.list
# 最后安装
sudo apt-get update
sudo apt-get install docker-ce
# 如果你之前安装过 docker, 请先删掉
sudo yum remove docker docker-common docker-selinux docker-engine
# 安装一些依赖
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
# 根据你的发行版下载 repo 文件: CentOS/RHEL
wget -O /etc/yum.repos.d/docker-ce.repo https://download.docker.com/linux/centos/docker-ce.repo
# 把软件仓库地址替换为 TUNA:
sudo sed -i 's+download.docker.com+mirrors.tuna.tsinghua.edu.cn/docker-ce+' /etc/yum.repos.d/docker-ce.repo
# 最后安装:
sudo yum makecache fast
sudo yum install docker-ce
Install: Install Docker Engine on Ubuntu
More: Linux post-installation steps for Docker Engine
Ubuntu:
# Uninstall any such older versions before attempting to install a new version
sudo apt-get remove docker docker-engine docker.io containerd runc
# Update the apt package index and install packages to allow apt to use a repository over HTTPS
sudo apt-get update
sudo apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release
# Add Docker’s official GPG key
sudo mkdir -m 0755 -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
# Use the following command to set up the repository
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# Update the apt package index
sudo apt-get update
# Install Docker Engine, containerd, and Docker Compose.
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
# Verify that the Docker Engine installation is successful by running the hello-world image:
sudo docker run hello-world
sudo groupadd docker
sudo usermod -aG docker $USER
docker run hello-world
To automatically start Docker and containerd on boot for other Linux distributions using systemd, run the following commands:
sudo systemctl enable docker.service
sudo systemctl enable containerd.service
To stop this behavior, use disable
instead.
sudo systemctl disable docker.service
sudo systemctl disable containerd.service
访问连接: https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors
针对 Docker 客户端版本大于
1.10.0
的用户
您可以通过修改 daemon 配置文件 /etc/docker/daemon.json
来使用加速器
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://xxx.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
{
"registry-mirrors": [
"http://hub-mirror.c.163.com",
"https://registry.cn-hangzhou.aliyuncs.com",
"https://xxx.mirror.aliyuncs.com",
"https://docker.mirrors.ustc.edu.cn"
]
}
/etc/docker/daemon.json
中加入(如果没有则新建一个):{
"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn/"]
}
重新启动 dockerd:
sudo systemctl restart docker
/etc/default/docker
中的 DOCKER_OPTS
中配置 Hub 地址:在配置文件 /etc/default/docker
中的 DOCKER_OPTS
中配置 Hub 地址:
DOCKER_OPTS="--registry-mirror=https://docker.mirrors.ustc.edu.cn/"
重新启动服务:
sudo service docker restart
检查 Docker Hub 是否生效
在命令行执行 docker info
, 如果从结果中看到了如下内容, 说明配置成功。
Registry Mirrors:
https://docker.mirrors.ustc.edu.cn/
官方: https://docs.docker.com/compose/install/
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。