Using a dedicated Docker network

Use this method to avoid having to expose PostreSQL port to the host’s network or if you have other PostgreSQL instances but still want to use the default port of 5432 for this installation.

  1. Create the network:

    docker network create mayan
    
  2. Launch the PostgreSQL container with the network option and remove the port binding (-p 5432:5432):

    docker run \
    -d \
    --name mayan-edms-postgres \
    --network=mayan \
    --restart=always \
    -e POSTGRES_USER=mayan \
    -e POSTGRES_DB=mayan \
    -e POSTGRES_PASSWORD=mayanuserpass \
    -v /docker-volumes/mayan-edms/postgres:/var/lib/postgresql/data \
    postgres:9.6-alpine
    
  3. Launch the Redis container with the network option and remove the port binding (-p 6379:6379):

    docker run \
    -d \
    --name mayan-edms-redis \
    --network=mayan \
    -v /docker-volumes/mayan-edms/redis:/data \
    redis:5.0-alpine \
    redis-server \
    --databases \
    "2" \
    --maxmemory-policy \
    allkeys-lru \
    --save \
    "" \
    --requirepass mayanredispassword
    
  4. Launch the Mayan EDMS container with the network option and change the database hostname to the PostgreSQL container name (mayan-edms-postgres) instead of the IP address of the Docker host (172.17.0.1):

    docker run \
    -d \
    --name mayan-edms \
    --network=mayan \
    --restart=always \
    -p 80:8000 \
    -e MAYAN_DATABASES="{'default':{'ENGINE':'django.db.backends.postgresql','NAME':'mayan','PASSWORD':'mayanuserpass','USER':'mayan','HOST':'mayan-edms-postgres'}}" \
    -e MAYAN_CELERY_BROKER_URL="redis://:mayanredispassword@mayan-edms-redis:6379/0" \
    -e MAYAN_CELERY_RESULT_BACKEND="redis://:mayanredispassword@mayan-edms-redis:6379/1" \
    -v /docker-volumes/mayan-edms/media:/var/lib/mayan \
    mayanedms/mayanedms:3.5.3