Install Docker-Compose on Linux CentOS6.8
Try to change to CentOS7 to run docker
1. Run the following command to download the latest version of Docker Compose
curl -L https://github.com/docker/compose/releases/download/1.5.2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
Note that the version is 1.5.2, the latest version runs on CentOS6.8 and returns the following error
docker-compose: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /tmp/_MEIXH1zkM/libz.so .1)
2. Give executable permission to the binary file application
sudo chmod +x /usr/local/bin/docker-compose
3. Test installation
$ docker-compose --version
docker-compose version 1.5.2, build 9e633ef
The following are mainly from CentOS6.x to install Docker and Docker Compose
4. Docker Compose version problem
When running docker-compose build, we will be prompted that our Docker version is too low and require an upgrade of Docker.
The current docker version is 1.7.1, and the docker-compose version is 1.5.2
Five, docker-compose.yml problem
V1 version of docker-compose.yml is only supported up to docker-compose 1.6.x. Later versions of docker-compose no longer support the V1 version of docker-compose.yml. The main difference in the format of the docker-compose.yml file
that needs to be changed to V1 V1 is:
- no version declaration at the beginning
- no services declaration
- does not support depends_on
- Named volumes, networks, build arguments declarations are not supported
- I haven't used other ones, so I didn't study the difference carefully.
Let's take an example to be more intuitive!
V2 版本的 docker-compose.yml
version: "2"
services:
redis:
image: "redis:alpine"
ports:
- "6389:6379"
volumes:
- "./data/redis/data:/data"
mysql:
build: ./builds/mysql
ports:
- "3386:3306"
volumes:
- "./data/mysql/data:/var/lib/mysql"
- "./data/mysql/conf:/etc/mysql/conf.d"
restart: always
environment:
MYSQL_DATABASE: solar
MYSQL_USER: root
MYSQL_PASSWORD: Huofigo2015
MYSQL_ROOT_PASSWORD: Huofigo2015
api:
depends_on:
- mysql
- redis
build:
context: ./builds/api
ports:
- "8388:8080"
volumes:
- "./target/solar-app-0.0.1-SNAPSHOT.jar:/app/solar-app.jar"
entrypoint:
- "java"
- "-jar"
- "/app/solar-app.jar"
restart: always
改成 V1 版本的 docker-compose.yml 后
redis:
image: "redis:alpine"
ports:
- "6389:6379"
volumes:
- "./data/redis/data:/data"
mysql:
build: ./builds/mysql
ports:
- "3386:3306"
volumes:
- "./data/mysql/data:/var/lib/mysql"
- "./data/mysql/conf:/etc/mysql/conf.d"
restart: always
environment:
MYSQL_DATABASE: solar
MYSQL_USER: root
MYSQL_PASSWORD: Huofigo2015
MYSQL_ROOT_PASSWORD: Huofigo2015
api:
build: ./builds/api
ports:
- "8388:8080"
volumes:
- "./target/solar-app-0.0.1-SNAPSHOT.jar:/app/solar-app.jar"
links:
- mysql
- redis
entrypoint:
- "java"
- "-jar"
- "/app/solar-app.jar"
restart: always