Skip to content

Instantly share code, notes, and snippets.

@WesleyBatista
Last active September 1, 2019 15:12
Show Gist options
  • Save WesleyBatista/dc9ae60901366c1a1de286e5d7cfd5be to your computer and use it in GitHub Desktop.
Save WesleyBatista/dc9ae60901366c1a1de286e5d7cfd5be to your computer and use it in GitHub Desktop.
Running the main databases on raspberry pi

setup

mongo

  1. create the data dir mkdir -p /home/pi/mongo/data
  2. run the following docker command:
    docker run --restart always -d -p 27017:27017 -p 28017:28017 -e AUTH=no -v /home/pi/mongo/data:/data/db --name mongo izone/arm:mongo-3.0.9
    

    source: https://github.com/luvres/armhf

postgres

  1. create the data dir mkdir -p /home/pi/postgres/data

  2. create the root password and store it at /home/pi/postgres/root_password

  3. run the following docker command:

    docker run --restart always -d -p 5432:5432 -v /home/pi/postgres/root_password:/run/secrets/postgres-passwd -v /home/pi/postgres/data:/var/lib/postgresql/data -e="POSTGRES_PASSWORD_FILE=/run/secrets/postgres-passwd" --name postgres postgres:11.5-alpine
    

    convenient command for psql:

    docker run -it --rm postgres:11.5-alpine psql -h $(dig raspberrypi +short) -U postgres
    

redis

  1. create the data dir mkdir -p /home/pi/redis/data
  2. add the config to /home/pi/redis/redis.conf
  3. run the following docker command:
    docker run --restart always -d -p 6379:6379 -v "/home/pi/redis/data":/data -v /home/pi/redis/redis.conf:/etc/redis/redis.conf --name redis redis:5.0.5-alpine3.10 redis-server /etc/redis/redis.conf
    

mysql

  1. create the data dir mkdir -p /home/pi/mysql/data
  2. run the docker command:
    docker run --restart always -d -p 3306:3306 -v /home/pi/mysql/data/:/var/lib/mysql -e="MYSQL_ROOT_PASSWORD=xxxxxxxxxxxxxxx" --name mysql jsurf/rpi-mariadb:latest
    

    source: https://github.com/JSurf/docker-rpi-mariadb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment