换源aliyun
1.卸载老版本
sudo apt-get remove docker docker-engine docker-ce docker.io |
2.添加秘钥
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add - |
3.设置存储库
sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable" |
安装
1.安装
sudo apt-get update |
2.查看版本
docker version |
3.查看状态
systemctl status docker |
4.启动docker
sudo systemctl start docker |
5.设置开机启动
sudo systemctl enable docker |
6.demo验证
sudo docker run hello-world |
7.进入容器
docker run -it ubuntu bash |
8.清空
docker system prune |
9.换源
mkdir -p /etc/docker |
输入以下内容{
"registry-mirrors": [
"https://2a6bf1988cb6428c877f723ec7530dbc.mirror.swr.myhuaweicloud.com",
"https://docker.m.daocloud.io",
"https://hub-mirror.c.163.com",
"https://mirror.baidubce.com",
"https://your_preferred_mirror",
"https://dockerhub.icu",
"https://docker.registry.cyou",
"https://docker-cf.registry.cyou",
"https://dockercf.jsdelivr.fyi",
"https://docker.jsdelivr.fyi",
"https://dockertest.jsdelivr.fyi",
"https://mirror.aliyuncs.com",
"https://dockerproxy.com",
"https://mirror.baidubce.com",
"https://docker.m.daocloud.io",
"https://docker.nju.edu.cn",
"https://docker.mirrors.sjtug.sjtu.edu.cn",
"https://docker.mirrors.ustc.edu.cn",
"https://mirror.iscas.ac.cn",
"https://docker.rainbond.cc"
]
}
重启systemctl daemon-reload
systemctl restart docker
doker-compose
1.安装
sudo apt install docker-compose |
2.解决连接问题
ERROR: Couldn’t connect to Docker daemon at http+docker://localunixsocket - is it running?
If it’s at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
sudo gpasswd -a ${USER} docker |
docker on WSL
- 下载并安装docker
下载地址为: docker
一路默认安装
- 配置docker
通过搜索或者开始键,打开docker,点击设置
点击resource,将对应的wsl的环境打开
- 验证
若要确认已安装 Docker,请打开 WSL 发行版(例如 Ubuntu),并通过输入 docker --version
来显示版本和内部版本号
通过使用 docker run hello-world
运行简单的内置 Docker 映像,测试安装是否正常工作