1.添加 Docker 官方 GPG 密钥
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
2.添加 Docker 包源:
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
3.安装GPG证书,导入官方签名密钥
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
4.设置稳定版仓库
sudo apt-get install -y lsb_release
sudo add-apt-repository "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
5.验证key
sudo apt-key fingerprint ABF5BD827BD9BF62
6.安装最新版本
sudo apt-get install docker-ce docker-ce-cli containerd.io
7.查看可获取的版本
apt-cache madison docker-ce
8.安装指定版本
sudo apt-get install docker-ce=5:24.0.7-1~ubuntu.20.04~focal docker-ce-cli=5:24.0.7-1~ubuntu.20.04~focal containerd.io
9.docker操作命令
sudo service docker start
sudo service docker stop
sudo service docker restart
sudo systemctl status docker
10.docker镜像操作:
docker search mysql
docker pull hackeryx/ubuntu:16.04
docker image rm 镜像名或镜像
11.Docker操作容器
docker run [option] 镜像名:tag [向启动容器中传入的命令]
docker exec -it ubuntu /bin/bash
docker ps -a
docker container stop 容器名或容器id
docker container start 容器名或容器id
docker container kill 容器名或容器id
docker container rm 容器名或容器id
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。