Docker 安装文档:https://docs.docker.com/install/linux/docker-ce/centos/
- 卸载系统之前的docker sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine
- 安装Docker-CE
- 安装必须的依赖 sudo yum install -y yum-utils device-mapper-persistent-data lvm2
- 设置docker repo 的yum 位置 sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
- 安装docker,以及docker-cli sudo yum install docker-ce docker-ce-cli containerd.io
- 启动docker
sudo systemctl start docker
- 查看docker版本 docker -v
- 查看docker 镜像列表 docker images
- 设置开机自启动 sudo systemctl enable docker
- 测试docker 常用命令,注意切换到root 用户下 https://docs.docker.com/engine/reference/commandline/docker/
- 配置docker 镜像加速 阿里云,容器镜像服务针对Docker 客户端版本大于1.10.0 的用户您可以通过修改daemon 配置文件/etc/docker/daemon.json 来使用加速器
常见错误:
1、镜像名重复或已存在
代码语言:javascript复制docker: Error response from daemon: Conflict. The container name "/mysql" is already in use by container "9f52d88a12eadbfb81707191fe2c2090f5dcfbd1f6a7461d97e32ad947c2feab". You have to remove (or rename) that container to be able to reuse that name.
解法方法:
- 先查看镜像 docker ps -a [root@xiaobear ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 9f52d88a12ea mysql "docker-entrypoint.s…" 7 minutes ago Exited (1) 7 minutes ago mysql
- 移除
CONTAINER ID
名 docker rm 9f52d88a12ea - 再创建新的容器