安装 Docker

正常安装

https://docs.docker.com/engine/install/debian/#install-using-the-repository

镜像安装

# 清理:
sudo apt-get remove -y docker docker-engine docker.io
# 安装依赖:
sudo apt-get install -y 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 -# 添加软件仓库:
sudo add-apt-repository \
"deb [arch=amd64] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/debian \
$(lsb_release -cs) \
stable"
# 安装
sudo apt-get update -y
sudo apt-get install -y docker-ce

https://mirrors.tuna.tsinghua.edu.cn/help/docker-ce/

设置加速镜像

sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<EOF
{
"registry-mirrors": [
"https://ustc-edu-cn.mirror.aliyuncs.com/",
"https://hub-mirror.c.163.com/"
]
}
EOF

重启 docker 并设置开机自启

sudo systemctl enable docker
sudo systemctl daemon-reload
sudo systemctl restart docker

允许运行普通账号直接执行 docker 命令

sudo groupadd docker
sudo usermod -aG docker $USER
newgrp docker

https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user

安装 Docker Compose

export LATEST_VERSION=$(wget -qO- -t1 -T2 "https://api.github.com/repos/docker/compose/releases/latest" | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g')
sudo curl -L https://github.com/docker/compose/releases/download/$LATEST_VERSION/docker-compose-linux-`uname -m` > ./docker-compose
sudo chmod +x ./docker-compose
sudo mv ./docker-compose /usr/local/bin/docker-compose

若下载缓慢请使用 curl --proxy socks5://ip:port -L {path} 参数设置代理.

 

via。https://6xyun.cn/article/137 

 

更新系统包和必要的依赖项

sudo apt update sudo apt install apt-transport-https ca-certificates curl gnupg2 software-properties-common

安装 Docker

使用arch查看arch类型(e.g. arm64 / amd64) 将Docker CE存储库添加到APT中

curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"

执行安装

sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io
sudo systemctl status docker
docker -v

安装 Docker-Compose

方法一

sudo curl -L "https://github.com/docker/compose/releases/download/v2.2.3/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version

方法二

sudo apt update
sudo apt install -y python3-pip libffi-dev
sudo pip3 install docker-compose

docker-compose 组合命令

运行 docker-compose.yml 文件

docker-compose up -d

停止所有正在运行的容器

docker-compose down

暂停和取消正在运行的容器

docker-compose pause docker-compose unpause

列出所有正在运行的容器

docker-compose ps

检查驱动服务的日志

docker-compose logs

其他

启用IPv6

echo "iface ens3 inet6 dhcp" >> /etc/network/interfaces
reboot

 

 

via。https://nies.live/d/105

最后修改:2023 年 02 月 19 日 12 : 05 AM