ubuntu下安装Docker
命令行安装
https://mirrors.tuna.tsinghua.edu.cn/help/docker-ce/
https://docs.docker.com/engine/install/
桌面版安装
https://www.docker.com/products/docker-deskto
1.命令行安装
使用国内镜像安装速度快, 参考清华大学开源软件镜像站:https://mirrors.tuna.tsinghua.edu.cn/
点击问号可以导航到安装帮助页面
export DOWNLOAD_URL="https://mirrors.tuna.tsinghua.edu.cn/docker-ce"
# 如您使用 curl
curl -fsSL https://get.docker.com/ | sh
# 如您使用 wget
wget -O- https://get.docker.com/ | sh
sudo apt-get install -y uidmap
#rootless 运行
dockerd-rootless-setuptool.sh install
#root 运行
dockerd-rootless-setuptool.sh uninstall
2.权限问题
需要将当前用户增加到docker群组.
Manage Docker as a non-root user
The docker daemon binds to a Unix socket instead of a TCP port. By default that Unix socket is owned by the user root and other users can only access it using sudo. The docker daemon always runs as the root user.
If you don’t want to use when you use the docker command, create a Unix group called docker and add users to it. When the docker daemon starts, it makes the ownership of the Unix socket read/writable by the docker group
#将登陆用户加入到docker用户组中
sudo gpasswd -a $USER docker
#更新用户组
newgrp docker
#测试docker命令是否可以使用sudo正常使用
docker info
3.测试 Docker 是否安装成功
#运行hello-world docker
docker run hello-world
4.Docker镜像加速
docker_61">4.1.docker镜像加速源
原始仓库 | 镜像仓库 |
---|---|
docker.io | 阿里云docker仓库镜像 https://hub-mirror.c.163.com https://dockerproxy.com https://registry.docker-cn.com/ https://docker.mirrors.ustc.edu.cn/ |
quay.io | quay.mirrors.ustc.edu.cn |
- 阿里云Docker需要登陆访问,左侧菜单选中镜像加速器就可以看到你的专属地址了.
4.2.镜像加速设置
经过测试发现阿里云加速速度最快
#1.编辑文件/etc/docker/daemon.json
sudo touch /etc/docker/daemon.json
sudo vim /etc/docker/daemon.json{"registry-mirrors":["https://hub-mirror.c.163.com","https://registry.docker-cn.com/"]}
#2.重启服务
sudo systemctl daemon-reload
sudo systemctl restart docker#3.检查加速器
docker info
#显示如下内容说明加速器生效
Registry Mirrors:https://hub-mirror.c.163.com/https://registry.docker-cn.com/
docker_91">卸载 docker
sudo apt-get purge docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extrassudo rm -rf /var/lib/docker
sudo rm -rf /var/lib/containerd