commit
e654ba63ab
@ -0,0 +1 @@
|
||||
data
|
@ -0,0 +1,13 @@
|
||||
# Local Docker DB
|
||||
|
||||
## What?
|
||||
A collection of Docker Compose files I've used to quickly spin local databases of various sorts.
|
||||
|
||||
## Why?
|
||||
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.
|
||||
|
||||
## How?
|
||||
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/).
|
||||
|
||||
## Local Persistence
|
||||
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.
|
@ -0,0 +1,18 @@
|
||||
# Enter the Container w/ Bash
|
||||
|
||||
`docker-compose exec --user root db /bin/bash`
|
||||
|
||||
# Enter the Mongo Shell
|
||||
|
||||
`docker-compose exec --user root db mongo`
|
||||
|
||||
# Create a DB w/ User
|
||||
|
||||
While in the shell, run the following:
|
||||
|
||||
```
|
||||
use admin;
|
||||
db.auth("user", "password");
|
||||
use myDatabase;
|
||||
db.createUser({user: "user", pwd: "password", roles:[{role: "readWrite" , db:"myDatabase"}]});
|
||||
```
|
@ -0,0 +1,12 @@
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
db:
|
||||
image: mongo:latest
|
||||
volumes:
|
||||
- ./data:/data/db
|
||||
ports:
|
||||
- 27017:27017
|
||||
environment:
|
||||
MONGO_INITDB_ROOT_USERNAME: user
|
||||
MONGO_INITDB_ROOT_PASSWORD: password
|
@ -0,0 +1,17 @@
|
||||
# Enter the Container w/ Bash
|
||||
|
||||
`docker-compose exec --user root db /bin/bash`
|
||||
|
||||
# Enter the MySQL Shell
|
||||
|
||||
`docker-compose exec --user root db mysql -u root -p`
|
||||
|
||||
When prompted, enter `root` as the password.
|
||||
|
||||
# Create a DB
|
||||
|
||||
While inside the shell, run the following:
|
||||
|
||||
```
|
||||
CREATE DATABASE mydatabase;
|
||||
```
|
@ -0,0 +1,13 @@
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
db:
|
||||
container_name: docker-local-mysql
|
||||
image: mysql:5.7.21
|
||||
volumes:
|
||||
- "./data:/var/lib/mysql"
|
||||
restart: always
|
||||
ports:
|
||||
- 3306:3306
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: root
|
Loading…
Reference in new issue