Giter VIP home page Giter VIP logo

docker-databases's Introduction

Databases in Docker

Shell helper for launching common databases in docker containers.

Requirements

  • Docker 0.8+ (from docker.io)

Supported Databases

Installation

  1. Git clone this repository git clone [email protected]:thestonefox/docker-databases.git
  2. cd to correct directory cd docker-databases

Usage

Note:

You may need to run the below commands with sudo depending on how you installed docker.

###Starting a db container

./ddb.sh <db-type>

Example: ./ddb.sh mysql

###Terminating a db container

./ddb-kill.sh <container-name>

Example: ./ddb-kill.sh mysqldb

Runtime Options

You can customise the database settings when running the ddb.sh script.

# mysql/postgresql only
- username
- password
- database name

# all types
- docker container name

The below example will create a new docker mysql container with the following details:

  • mysql username: myuser
  • mysql password: mypass
  • mysql default database: mytestdb
  • docker container name: mysqldb

###Creating the docker db container

  • Step 1. Run the ddb.sh script for mysql:
./ddb.sh mysql
  • Step 2. You will be prompted to enter a default username:
Please enter db username [default: root]: myuser
  • Step 3. You will be prompted to enter a default password:
Please enter db password [default: password]: mypass
  • Step 4. You will be prompted to enter a default database schema name:
Please enter db name [default: test]: mytestdb
  • Step 5. You will be prompted to enter a docker container name:
Please enter docker container name [default: mysql]: mysqldb
  • Step 6. When the above details have been entered, the docker container will pull and run and return the container ID
  • Step 7. Run docker ps to list the running docker containers
CONTAINER ID        IMAGE                        COMMAND               CREATED             STATUS              PORTS                                        NAMES
9f7c38765cd2        orchardup/mysql:latest       /usr/local/bin/run    3 seconds ago       Up 2 seconds        0.0.0.0:3306->3306/tcp                       mysqldb  

You should now see your running docker mysql container with the name "mysqldb" with the default mysql port (3306) already mapped through to the container.

###Terminating the container

  • Step 1. Run the ddb-kill.sh script passing in the container name to terminate
./ddb-kill.sh mysqldb
  • Step 2. The container will be stopped and then deleted
  • Step 3. Run docker ps to list the running docker containers
CONTAINER ID        IMAGE                        COMMAND               CREATED             STATUS              PORTS                                        NAMES

You should now see your docker database container has been removed from the containers list.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.