ubuntn安装docker
- 卸载旧版本
sudo apt-get remove docker docker-engine docker.io containerd runc
- 获取软件最新源
sudo apt-get update
- 安装apt依赖包
sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common
- 安装gpg证书
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
- 验证
sudo apt-key fingerprint 0EBFCD88
- 设置稳定版仓库
sudo add-apt-repository "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
- 更新apt包索引
sudo apt-get update
- 安装最新版docker
sudo apt-get install docker-ce docker-ce-cli containerd.io
- 查看docker版本
docker --version
- 更换获取源
新建文件 /etc/docker/deamon.json
文件添加以下内容
{
"registry-mirrors" : [
"https://registry.docker-cn.com",
"http://hub-mirror.c.163.com",
"https://docker.mirrors.ustc.edu.cn/",
"https://yxzrazem.mirror.aliyuncs.com",
"https://docker.kubesre.xyz",
"https://dc.j8.work",
"https://docker.registry.cyou",
"https://docker.hlyun.org",
"https://docker.chenby.cn",
"https://docker.jsdelivr.fyi",
"https://docker-mirrors.mjjman.com",
"https://docker.kubesre.xyz",
"https://huecker.io",
"https://dockerhub.timeweb.cloud",
"https://docker.registry.cyou",
"https://docker-cf.registry.cyou",
"https://dockercf.jsdelivr.fyi",
"https://dockertest.jsdelivr.fyi"
]
}
- 重启docker
sudo systemctl daemon-reload
sudo systemctl restart docker
- 拉取并运行hello-word
sudo docker run hello-world
- 查看docker镜像列表
sudo docker images
- 启动docker
systemctl start docker
- 停止docker
systemctl stop docker
- 重启docker
systemctl restart docker
- 设置docker开机启动
sudo systemctl enable docker
docker安装nginx
sudo docker search nginx
sudo docker pull nginx
sudo docker images
sudo docker run -d --name nginx01 -p 3344:80 nginx