安装卸载 docker (以下命令以root权限执行)
1.升级yum源
yum -y update
cat /etc/redhat-release 确认时CentOS7及以上版本
2.卸载旧版docker
yum -y remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-selinux docker-engine-selinux docker-engine
3.安装相关工具类
yum -y install -y yum-utils device-mapper-persistent-data lvm2
4.配置docker仓库(直接配置阿里云的源)
5.aliyun的源
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
6.安装docker
yum -y install docker-ce
7.启动docker
systemctl start docker
8.验证docker
docker run hello-world
出现以下内容表示安装成功
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
9bb5a5d4561a: Pull complete
Digest: sha256:f5233545e43561214ca4891fd1157e1c3c563316ed8e237750d59bde73361e77
Status: Downloaded newer image for hello-world:latest
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:
9.设置开机自启
chkconfig docker on
Linux centOS7使用如下命令
systemctl enable docker/docker.service
systemctl diable docker/docker.service // 关闭开机自启
10.卸载docker ce
yum remove docker-ce
rm -rf /var/lib/docker
11.配置163镜像 解决卡顿(可选)
// 编辑该文件
vi /etc/docker/daemon.conf
// 填写以下代码
{
"registry-mirrors": ["http://hub-mirror.c.163.com"]
}
registry-mirrors 为镜像地址
docker 版本<20 graph 为存储目录 建议不要使用默认的 否则空间会不够用
docker 版本>20 graph已经弃用 需使用 data-root
// 重启docker
systemctl daemon-reload
systemctl restart docker
安装 docker-compose
1.github 安装
curl -L https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
修改版本下载不同版本 1.27.4/2.2.2
2.手动安装
手动下载(各种渠道 比如百度)
博主已经下载好了(1.27.4 与 2.2.2 版本) 并上传到gitee 地址: 博主docker-compose地址
下载好之后 上传到系统 /usr/local/bin 目录 并改名为 docker-compose
3.授权
chmod +x /usr/local/bin/docker-compose
4.检查版本
1.27.4
docker-compose -version
2.2.2
docker-compose version
转载于