Switch branches/tags
Nothing to show
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
README.md

README.md

Commands for Quick Docker Servers

MongoDB

Keep data in container volume

docker run -d \
  --name mongodb \
  -p 127.0.0.1:27017:27017 \
  mongo:3 bash -c 'mongod --logappend --storageEngine=wiredTiger'

Keep data in 'mounted volume/path' at $HOME/mongodb

mkdir -p $HOME/mongodb/data
docker run -d \
  --name mongodb \
  --restart on-failure:15 \
  -p 127.0.0.1:27017:27017 \
  -v $HOME/mongodb:/data \
  mongo:3 bash -c 'mongod --logpath /data/mongodb.log --logappend --dbpath /data/data --storageEngine=wiredTiger'

Postgres

Note: To persist data in the host filesystem, add this volume option: -v $HOME/postgres:/var/lib/postgresql/data/db

Store data inside container volume

docker run -d \
  --name postgresdb \
  --restart on-failure:15 \
  -p 127.0.0.1:5432:5432 \
  -e PGDATA=/var/lib/postgresql/data/db \
  -e POSTGRES_USER=$USER \
  -e POSTGRES_DB=$USER \
  -e POSTGRES_INITDB_ARGS="--data-checksums" \
  postgres:9.6-alpine

IMPORTANT: If you see the following error, see fix below:

$ psql
psql: could not connect to server: Socket operation on non-socket
        Is the server running locally and accepting
        connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

To access server via your 'local' terminal and code: configure connection with the local address 127.0.0.1

# Option 1: Explicitly set `--host` CLI argument
createdb --host 127.0.0.1 foobar

# Option 2: Set host for all postgres CLI tools via $PGHOST
export PGHOST=127.0.0.1
psql # should work

MySQL

CRITICAL TODO: CHANGE PASSWORD!!!

# CRITICAL TODO: CHANGE PASSWORD!!!
docker run -d \
  -p 127.0.0.1:3306:3306 \
  --name mysql-$USER \
  -e MYSQL_DATABASE=$USER \
  -e MYSQL_ROOT_HOST='172.*.*.*' \
  -e MYSQL_ROOT_PASSWORD='p@ssw0rd' \
  mysql/mysql-server:5.7

Keep data in 'mounted' volume/path at $HOME/mysql

CRITICAL TODO: CHANGE PASSWORD!!!

mkdir -p $HOME/mysql
docker run -d \
  -v $HOME/mysql:/var/lib/mysql \
  -p 127.0.0.1:3306:3306 \
  --name mysql-$USER \
  -e MYSQL_DATABASE=$USER \
  -e MYSQL_ROOT_HOST='172.*.*.*' \
  -e MYSQL_ROOT_PASSWORD='p@ssw0rd' \
  mysql/mysql-server:5.7

ElasticSearch

cd $HOME/elastic
docker run -d \
  --name elastic01 \
  -p 127.0.0.1:9200:9200 \
  -p 127.0.0.1:9300:9300 \
  -v $HOME/elastic:/data \
  elasticsearch bash -c 'elasticsearch --cluster.name es_cluster --node.name elastic01 --path.data /data/db --path.logs /data/logs '

Misc: Password Generator

pwgen -N 1 -s 20