Recently, I work on several projects that has different kind of databases. It requires lots of setups and managing overhead.
For development purpose, I have to setup the development environment to help my fellas mitigate the overhead of setting up their machine for each kind of database on each project.
Here are my snippets that might help you getting started to setup the dev environment quickly as possible. The snippet is just a boilerplate. You can add, edit or remove anything as you wish to match the project requirements.
Snippets
To run the snippets:
- Create
docker-compose.yml
file and paste the selected database below. - Runs the
$ docker-compose up -d
command to spawn the environment. - If you're not using it, just runs
$ docker-compose stop
to stop the services or$ docker-compose down
to stop and remove all the services, containers, networks and images.
MySQL
services:
database:
image: mysql:5.7.32
ports:
- 3306:3306
environment:
- MYSQL_ALLOW_EMPTY_PASSWORD=yes
restart: always
MariaDB
version: '3.1'
services:
mariadb:
image: mariadb
restart: 'on-failure'
ports:
- 3306:3306
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:?err}
volumes:
- ./mariadb/data:/var/lib/mysql
MongoDB + Mongo Expree docker-compose.yml
file.
version: '3.1'
services:
mongo:
image: mongo
restart: always
volumes:
- ./mongo/data:/data/db
ports:
- 27017:27017
environment:
MONGO_INITDB_ROOT_USERNAME: root # change your username
MONGO_INITDB_ROOT_PASSWORD: example # change your password
mongo-express:
image: mongo-express
restart: always
ports:
- 8081:8081
environment:
ME_CONFIG_MONGODB_ADMINUSERNAME: root
ME_CONFIG_MONGODB_ADMINPASSWORD: example
ME_CONFIG_MONGODB_URL: mongodb://root:example@mongo:27017/
Redis
services:
redis:
image: redis:6.2.1
ports:
- 6379:6379
restart: always
Top comments (0)