CentOS docker/docker-compose 安装与卸载
安装docker
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
这里添加阿里云的镜像地址,官方国内下载很慢
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
更新 yum 缓存
sudo yum makecache fast
安装 Docker-ce (最新版):
sudo yum -y install docker-ce
安装指定版本Docker-ce
sudo yum -y install docker-ce-18.06.2.ce
启动 Docker 后台服务
sudo systemctl start docker
允许开机启动docker-ce服务
sudo systemctl enable docker.service
测试运行 hello-world
docker run hello-world
[root@k8s-node-1 man1]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete
Digest: sha256:6540fc08ee6e6b7b63468dc3317e3303aae178cb8a45ed3123180328bcc1d20f
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:
https://docs.docker.com/get-started/
[root@k8s-node-1 man1]#
安装docker-compose
Docker for Mac
、Docker for Windows
自带 docker-compose
二进制文件,安装 Docker 之后可以直接使用。
$ docker-compose --version
docker-compose version 1.17.1, build 6d101fb
二进制安装
$ sudo curl -L https://github.com/docker/compose/releases/download/1.17.1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
$ sudo chmod +x /usr/local/bin/docker-compose
创建软连接
[root@k8s-node-1 man1]# docker-compose --version
-bash: /usr/bin/docker-compose: 没有那个文件或目录
[root@k8s-node-1 man1]# ln -sf /usr/local/bin/docker-compose /usr/bin/docker-compose
[root@k8s-node-1 man1]# docker-compose --version
docker-compose version 1.17.1, build 6d101fb
PIP 安装
sudo pip install -U docker-compose
卸载docker
检查安装的组件
sudo yum list installed | grep docker
移除相关组件
$ sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-selinux \
docker-engine-selinux \
docker-engine\
docker-ce-cli
删除镜像、容器、卷及自定义的配置文件
rm -rf /var/lib/docker
卸载docker-compose
如果是二进制包方式安装的,删除二进制文件即可。
$ sudo rm /usr/local/bin/docker-compose
如果是通过 pip 安装的,则执行如下命令即可删除。
$ sudo pip uninstall docker-compose