Docker安装
Centos7
Centos7
安装DockerCE版本,官方教程
$ sudo yum remove docker \ docker-client \ docker-client-latest \ docker-common \ docker-latest \ docker-latest-logrotate \ docker-logrotate \ docker-engine$ sudo yum install -y yum-utils \ device-mapper-persistent-data \ lvm2$ sudo yum-config-manager \ --add-repo \ https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo$ sudo sed -i 's+download.docker.com+mirrors.aliyun.com/docker-ce+' /etc/yum.repos.d/docker-ce.repo$ sudo yum makecache- 安装默认版本
$ sudo yum install docker-ce- 安装特定版本
如果需要安装特定版本,按下面的方式执行。 先查看现有的版本
$ yum list docker-ce --showduplicates | sort -r显示如下
docker-ce.x86_64 3:18.09.8-3.el7 docker-ce-stable docker-ce.x86_64 3:18.09.7-3.el7 docker-ce-stable …
安装18.09.8 版本
$ sudo yum install docker-ce-18.09.8 docker-ce-cli-18.09.8 containerd.io$ sudo systemctl start docker设置开机启动
$ sudo systemctl enable docker上面2条命令可以合并
$ sudo systemctl enable docker --now$ sudo docker run hello-world输出如下
Hello from Docker!This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. (amd64) 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal.
To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID: https://hub.docker.com/
For more examples and ideas, visit: https://docs.docker.com/get-started/修改文件 /etc/docker/daemon.json,文件不存在就添加一个。添加配置(2024年8月9号还能使用)
{ "registry-mirrors": [ "https://hub.uuuadc.top", "https://docker.anyhub.us.kg", "https://dockerhub.icu", "https://docker.awsl9527.cn", "https://docker.m.daocloud.io", "https://docker.gs" ]}重载服务即可
$ sudo systemctl reload docker- 卸载
$ sudo yum remove docker-ce$ sudo yum autoremove- 删除目录
$ rm -rf /var/lib/docker删除 /var/lib/docker目录后,原先的镜像和容器都会被删除,请谨慎操作。如果只是为了更新,那么 /var/lib/docker 不需要删除。
- Docker基本命令 - Docker 常用命令速查
- CentOS安装docker-compose - 安装 docker-compose 工具
- Docker容器目录迁移 - 迁移容器数据目录到新磁盘
- Docker容器时区设置 - 修改容器时区配置