Skip to content

Instantly share code, notes, and snippets.

@harsh4870
Created February 22, 2023 16:08
Show Gist options
  • Save harsh4870/99cf486a60e3ffe74347b29f85cf1132 to your computer and use it in GitHub Desktop.
Save harsh4870/99cf486a60e3ffe74347b29f85cf1132 to your computer and use it in GitHub Desktop.
Docker compose Redis, MySQL, Elasticsearch, RabbitMQ, Adminer
version: "3.7"
services:
mysql:
container_name: mysql
image: mysql
command: --default-authentication-plugin=mysql_native_password
hostname: mysql
restart: always
volumes:
- $PWD/volume/mysql/data:/var/lib/mysql
ports:
- "3306:3306"
environment:
- MYSQL_PASSWORD=admin
- MYSQL_ROOT_PASSWORD=admin
- MYSQL_VERSION=latest
redis:
image: redis
restart: always
hostname: redis
container_name: redis
ports:
- '6379:6379'
volumes:
- $PWD/volume/redis/data:/data
elasticsearch:
image: elasticsearch:7.17.8
ports:
- '9200:9200'
volumes:
- '$PWD/volume/elasticsearch/data:/usr/share/elasticsearch/data'
environment:
- discovery.type=single-node
ulimits:
memlock: {soft: -1, hard: -1}
mem_limit: 1g
rabbitmq:
image: rabbitmq:3-management
restart: always
container_name: rabbitmq
hostname: rabbitmq
environment:
RABBITMQ_ERLANG_COOKIE: "cookie"
RABBITMQ_DEFAULT_VHOST: "/"
RABBITMQ_DEFAULT_USER: "guest"
RABBITMQ_DEFAULT_PASS: "guest"
ports:
- "5672:5672"
- "15672:15672"
healthcheck:
test: ["CMD", "rabbitmqctl", "status"]
interval: 100s
timeout: 10s
retries: 10
tty: true
volumes:
- '$PWD/volume/rabbitmq/data:/data'
adminer:
image: adminer:4.6.3
restart: always
environment:
ADMINER_DESIGN: "pappu687"
ports:
- 8080:8080
volumes:
redis_data:
driver: local
rabbitmq_data:
driver: local
@harsh4870
Copy link
Author

harsh4870 commented Feb 22, 2023

run-compose.sh

#!/bin/bash
docker pull mysql:5.7
docker pull rabbitmq:3-management
docker pull redis

mkdir -p volume

if [ ! -d "$PWD/volume/elasticsearch" ]; then
   mkdir -p volume/elasticsearch/data
   chmod 777 -R $PWD/volume/elasticsearch/
fi

if [ ! -d "$PWD/volume/mysql" ]; then
   mkdir -p volume/mysql/data
   chmod 777 -R $PWD/volume/mysql
fi

mkdir -p volume/rabbitmq/data
mkdir -p volume/redis/data


if [ -z $1 ]; then
  chmod 777 -R $PWD/volume/
  docker-compose -f docker-compose.yml up -d
elif [[ $1 = "up" ]]; then
  chmod 777 -R $PWD/volume/
elif [[ $1 = "down" ]]; then
  docker-compose -f docker-compose.yml down
fi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment