明天你会感谢今天奋力拼搏的你。
ヾ(o◕∀◕)ノヾ
更新本地软件包列表:sudo apt update
更新系统已安装软件包:sudo apt upgrade
安装依赖,用于通过HTTPS获取仓库:
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
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
使用命令更新Ubuntu源列表
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-compose-plugin
1.6、配置Docker国内镜像源
修改配置文件/etc/docker/daemon.json,如果没有新建一个
内容为:
{
"registry-mirrors": [
"https://dockerproxy.com",
"https://hub-mirror.c.163.com",
"https://mirror.baidubce.com",
"https://ccr.ccs.tencentyun.com"
]
}
重新启动一下docker
systemctl daemon-reload
systemctl restart docker
检查配置是否生效
sudo docker info
输出结果中Registry Mirrors下显示的URL为配置文件中的内容,则说明配置成功。
查看Docker服务状态:
systemctl status docker

启动Docker服务:
sudo systemctl start docker
设置Docker开机启动:
sudo systemctl enable docker
查看版本:
sudo docker version
列出本地的Docker镜像:
sudo docker images
Docker具体命令可参考:https://www.runoob.com/docker/docker-command-manual.html
sudo docker run hello-world

通过docker info命令,如果打印的最下面有如下警告,则表示没开启防火墙对桥接流量的处理。(生产环境建议开启)
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled
Docker 在 get.docker.com 和 test.docker.com 上提供了方便脚本,用于将快速安装 Docker Engine-Community 的边缘版本和测试版本。
测试版本安装:
curl -fsSL https://test.docker.com -o test-docker.sh
sudo sh test-docker.sh
最新版本:
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
注意:
删除安装包:
sudo apt-get purge docker-ce
删除镜像、容器、配置文件等内容:
sudo rm -rf /var/lib/docker
注意事项
如果遇到如下错误:curl: (35) OpenSSL SSL_connect: 连接被对方重置
可以试着用如下命令把证书重装一下:
sudo apt-get --reinstall install ca-certificates
https://www.runoob.com/docker/ubuntu-docker-install.html
全部评论