Skip to content

Setup docker mongodb, mysql, redis …

Michael Hulse edited this page Jul 5, 2022 · 3 revisions
docker pull mongo
docker pull mysql
docker pull redis

# List installed images:
docker images

Note: The above is probably not needed if you use docker-compose

Put a foo-docker-compose.yml somewhere on your path:

version: "3.8"

# docker-compose up --file=./foo-docker-compose.yml --detach

services:
  mysql:
    image: mysql:${TAG:-latest}
    ports:
      - "3306:3306"
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=root
    volumes:
      - mysql:/var/lib/mysql

  mongo:
    image: mongo:${TAG:-latest}
    ports:
      - "27017-27019:27017-27019"
    restart: always
    volumes:
      - mongo:/data/db

  redis:
    image: redis:${TAG:-latest}
    ports:
      - "6379:6379"
    restart: always

volumes:
  mysql:
    driver: local

  mongo:
    driver: local

Next to the yml file, create a shell script:

#!/bin/zsh

docker-compose --file ./foo-docker-compose.yml up --detach

Make the shell script executable:

chmod u+x foo-docker-compose

Then, from your command line, you can run foo-docker-compose.

Clone this wiki locally