docker-compose安装

2020/5/2 docker-compose

用来定义和运行复杂应用的Docker工具

# 安装

[root@iZ2ze3nu0s9j3xifggaiihZ ~]# curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   633  100   633    0     0   1011      0 --:--:-- --:--:-- --:--:--  1011
100 12.1M  100 12.1M    0     0  32592      0  0:06:30  0:06:30 --:--:-- 50201
[root@iZ2ze3nu0s9j3xifggaiihZ ~]# chmod +x /usr/local/bin/docker-compose
[root@iZ2ze3nu0s9j3xifggaiihZ ~]# docker-compose -v
docker-compose version 1.29.2, build 5becea4c
1
2
3
4
5
6
7
8

# 命令

后台启动:  docker-compose up -d
查看日志:  docker-compose logs -f --tail=100  容器名称
1
2

# 一键安装

vi /docker/install/install.sh

#!/bin/sh 
echo "======== 开始运行 ========"  


echo "卸载旧的docker容器"
	yum remove docker \
	>                   docker-client \
	>                   docker-client-latest \
	>                   docker-common \
	>                   docker-latest \
	>                   docker-latest-logrotate \
	>                   docker-logrotate \
	>                   docker-engine

echo "安装依赖包yum-utils"
	yum install -y yum-utils

echo "设置镜像仓库地址"
	 yum-config-manager \
	  --add-repo \
	   http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
	   
echo "安装docker相关的引擎"
	yum makecache fase
	yum install  -y docker-ce docker-ce-cli containerd.io

echo "启动docker"
	systemctl  start  docker
	systemctl enable docker

echo "使用阿里云镜像加速"
	sudo mkdir -p /etc/docker
	sudo tee /etc/docker/daemon.json <<-'EOF'
	{
	  "registry-mirrors": ["https://wxac5ila.mirror.aliyuncs.com"]
	}
	EOF
	sudo systemctl daemon-reload
	sudo systemctl restart docker

echo "安装docker-compose"
	curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose  
	chmod +x /usr/local/bin/docker-compose
	docker-compose -v
	

echo "======== 结束运行 ========"

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48

chmod +x /docker/install/install.sh

Last Updated: 2023/12/4 12:06:46