Docker
1. Docker 安装
卸载旧的版本
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
卸载之后,之前旧的目录会被保留, 默认的路径为 /var/lib/docker
通过repo方式安装
sudo yum install -y yum-utils
sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
安装最新版本
sudo yum install docker-ce docker-ce-cli containerd.io
(选择) 安装指定版本
yum list docker-ce --showduplicates | sort -r
sudo yum install docker-ce-18.09.1 docker-ce-cli-18.09.1 containerd.io
启动
systemctl start docker
systemctl enable docker
配置国内镜像加速
vim /etc/docker/daemon.json
{ "registry-mirrors": ["https://9cpn8tt6.mirror.aliyuncs.com"] }
重启docker
systemctl daemon-reload
systemctl restart docker
常用命令
docker save -o elasticsearch.tar zhengyang/elasticsearch:7.8.1
docker load -i elasticsearch.tar
docker ps -a
docker logs elasticsearch
docker inspect elasticsearch
docker network ls
...
2. Docker Compose 安装
安装
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
测试
docker-compose --version
常用命令
docker-compose -f xxx.yml up -d ## 创建并后台启动
docker-compose -f xxx.yml stop ## 停止
docker-compose -f xxx.yml down -v ## 停止并删除容器