Skip to content

Commit e654ba6

Browse files
committed
Add base README and configs for mysql & mongo.
0 parents  commit e654ba6

File tree

6 files changed

+74
-0
lines changed

6 files changed

+74
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
data

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Local Docker DB
2+
3+
## What?
4+
A collection of Docker Compose files I've used to quickly spin local databases of various sorts.
5+
6+
## Why?
7+
Because I've oft needed them, particularly when I just don't wanna deal with the hassle of spinning up a DB on my own system.
8+
9+
## How?
10+
Clone the repo or copy a `docker-compose.yml` file to your system, `cd` into that directory, and turn it on with `docker-compose up`. For a full reference on how to use Docker Compose, [go here](https://docs.docker.com/compose/reference/).
11+
12+
## Local Persistence
13+
In each setup, your data is configured to be stored locally in a `./data` directory. If that directory doesn't exist, it'll be created automatically.

mongo/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Enter the Container w/ Bash
2+
3+
`docker-compose exec --user root db /bin/bash`
4+
5+
# Enter the Mongo Shell
6+
7+
`docker-compose exec --user root db mongo`
8+
9+
# Create a DB w/ User
10+
11+
While in the shell, run the following:
12+
13+
```
14+
use admin;
15+
db.auth("user", "password");
16+
use myDatabase;
17+
db.createUser({user: "user", pwd: "password", roles:[{role: "readWrite" , db:"myDatabase"}]});
18+
```

mongo/docker-compose.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: '3'
2+
3+
services:
4+
db:
5+
image: mongo:latest
6+
volumes:
7+
- ./data:/data/db
8+
ports:
9+
- 27017:27017
10+
environment:
11+
MONGO_INITDB_ROOT_USERNAME: user
12+
MONGO_INITDB_ROOT_PASSWORD: password

mysql/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Enter the Container w/ Bash
2+
3+
`docker-compose exec --user root db /bin/bash`
4+
5+
# Enter the MySQL Shell
6+
7+
`docker-compose exec --user root db mysql -u root -p`
8+
9+
When prompted, enter `root` as the password.
10+
11+
# Create a DB
12+
13+
While inside the shell, run the following:
14+
15+
```
16+
CREATE DATABASE mydatabase;
17+
```

mysql/docker-compose.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: '3'
2+
3+
services:
4+
db:
5+
container_name: docker-local-mysql
6+
image: mysql:5.7.21
7+
volumes:
8+
- "./data:/var/lib/mysql"
9+
restart: always
10+
ports:
11+
- 3306:3306
12+
environment:
13+
MYSQL_ROOT_PASSWORD: root

0 commit comments

Comments
 (0)