Jacob Paris
← Back to all content

Create databases with Docker Compose

MongoDB

mongo:
image: prismagraphql/mongo-single-replica:5.0.3
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: password
MONGO_INITDB_DATABASE: admin
expose:
- 27017
ports:
- "27017:27017"
volumes:
- ${PWD}/init.mongodb:/docker-entrypoint-initdb.d/init.mongodb:ro
- dbdata:/data/db

PostGres

postgres:
image: postgres:14
ports:
- 5432:5432
restart: always
user: postgres
environment:
POSTGRES_PASSWORD: password
POSTGRES_HOST_AUTH_METHOD: password
volumes:
- ${PWD}/seed.sql:/docker-entrypoint-initdb.d/seed.sql
- dbdata:/var/lib/postgresql/data
Professional headshot

Hi, I'm Jacob

Hey there! I'm a developer, designer, and digital nomad with a background in lean manufacturing.

About once per month, I send an email with new guides, new blog posts, and sneak peeks of what's coming next.

Everyone who subscribes gets access to the source code for this website and every example project for all my tutorials.

Stay up to date with everything I'm working on by entering your email below.

Unsubscribe at any time.