Docker 安装(linux)
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
修改源文件 sudo vi /etc/docker/daemon.json
{
"registry-mirrors":
[
"https://docker.m.daocloud.io/",
"https://huecker.io/",
"https://dockerhub.timeweb.cloud",
"https://noohub.ru/",
"https://dockerproxy.com",
"https://docker.mirrors.ustc.edu.cn",
"https://docker.nju.edu.cn",
"https://xx4bwyg2.mirror.aliyuncs.com",
"http://f1361db2.m.daocloud.io",
"https://registry.docker-cn.com",
"http://hub-mirror.c.163.com",
"https://docker.mirrors.ustc.edu.cn"
]
}
刷新源配置
sudo systemctl daemon-reload
启动Docker
sudo systemctl restart docker
重启Docker
systemctl restart docker
下载镜像
docker pull 仓库名/镜像名:版本号
其他常用命令
搜索仓库镜像:docker search 镜像名
拉取镜像:docker pull 镜像名
查看正在运行的容器:docker ps
查看所有容器:docker ps -a
删除容器:docker rm container_id
查看镜像:docker images
删除镜像:docker rmi image_id
启动(停止的)容器:docker start 容器ID
停止容器:docker stop 容器ID
重启容器:docker restart 容器ID
启动(新)容器:docker run -it ubuntu /bin/bash
进入容器:docker attach 容器ID或docker exec -it 容器ID /bin/bash,推荐使用后者