centos上安装docker compose:
sudo curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
- 查看安装是否成功
docker-compose -v
docker-compose 文件样例:
version: '3'
services:
onlinedb:
container_name: 'onlinedb'
image: mysql:5.6
volumes:
- ./db/mysql:/var/lib/mysql/
- ./db/mysqld.cnf:/etc/mysql/mysql.conf.d/mysqld.cnf
ports:
- '3316:3306'
environment:
- MYSQL_ROOT_PASSWORD=111111
restart: on-failure:1
redis:
container_name: 'redis'
image: redis:latest
command: redis-server --requirepass 111111
ports:
- '6379:6379'
restart: on-failure:1
app:
container_name: 'app'
image: onlineexam/app:v1.0
ports:
- '8160:8080'
volumes:
- ./app/uploads:/home/file/studyOnline
- ./app/application.properties:/application.properties
depends_on:
- onlinedb
- redis