Anyone familiar with how to set up a Joplin server using Docker?

I have been attempting to set up a Joplin server using the sample docker-compose in a Portainer stack. I am not too familiar with running personal databases, but from what I understand the compose file should be sufficient to setup both the database and the server, as well as connect them. However, I cannot seem to make it work. After deploying the stack it seems to be running, but localhost:22300/login shows ‘invalid URL’; a Joplin server copyright notice, and a link to the same page.

Docker-compose file:

version: '3'

services:
    db:
        image: postgres:latest 
        container_name: postgres 
#        ports:
#            - 5433:5432 
        restart: unless-stopped 
        volumes:
            - /srv/dev-disk-by-uuid-e2c30baa-1378-4126-a5e0-f850fb3b9396/DOCKER/DATA/JOPLIN:/var/lib/postgresql/data # Make database files persistent. Otherwise data is lost when the container is destroyed.
        environment:
            - APP_PORT=22300 # port joplin-server is reachable at
            - POSTGRES_PASSWORD=mypassword123 #  database password
            - POSTGRES_USER=admin #  database user
            - POSTGRES_DB=joplin #  database name
    app:
        image: joplin/server:latest
        depends_on:
            - db
        ports:
            - "22300:22300" # Expose internal port to LAN
        restart: unless-stopped
        environment:
            - APP_BASE_URL=192.168.1.253:22300 
            - DB_CLIENT=pg
            - POSTGRES_PASSWORD=mypassword123 
            - POSTGRES_DATABASE=joplin 
            - POSTGRES_USER=admin
            - POSTGRES_PORT=5432 
            - POSTGRES_HOST=db

What have I missed?

APP_BASE_URL is wrong (if you want to connect from localhost it should be http://localhost:22300)

version: '3'

services:
    db:
        image: postgres:latest 
        container_name: postgres 
#        ports:
#            - 5433:5432 
        restart: unless-stopped 
        volumes:
            - /srv/dev-disk-by-uuid-e2c30baa-1378-4126-a5e0-f850fb3b9396/DOCKER/DATA/JOPLIN:/var/lib/postgresql/data # Make database files persistent. Otherwise data is lost when the container is destroyed.
        environment:
            - APP_PORT=22300 # port joplin-server is reachable at
            - POSTGRES_PASSWORD=mypassword123 #  database password
            - POSTGRES_USER=admin #  database user
            - POSTGRES_DB=joplin #  database name
    app:
        image: joplin/server:latest
        depends_on:
            - db
        ports:
            - "22300:22300" # Expose internal port to LAN
        restart: unless-stopped
        environment:
            - APP_BASE_URL=http://localhost:22300 # <- HERE
            - DB_CLIENT=pg
            - POSTGRES_PASSWORD=mypassword123 
            - POSTGRES_DATABASE=joplin 
            - POSTGRES_USER=admin
            - POSTGRES_PORT=5432 
            - POSTGRES_HOST=db

You can learn more about APP_BASE_URL here: https://hub.docker.com/r/joplin/server.

APP_BASE_URL is wrong (if you want to connect from localhost it should be http://localhost:22300)

Thank you. Unfortunately it does not seem to load at all with this. Containers are running but the ui does not load.

Run these two commands from the directory where you have docker-compose.yml, then navigate to http://localhost:22300.

  1. docker-compose down && rm -rf /srv/dev-disk-by-uuid-e2c30baa-1378-4126-a5e0-f850fb3b9396/DOCKER/DATA/JOPLIN
  2. docker-compose up --detach

There is no docker-compose file. I used the create stack feature in Portainer and wrote it in there.

I see. Anyway, you need to remove these two containers (app, db) completely and after that add them again to reload the configuration (restart isn’t enough). I don’t know how can you do it in Portainer.

Each time I attempt a different configuration I first remove the stack (which removes both containers and their data). So far it has made no difference.

Hmm, do you have an option to export logs from Portainer? This configuration works fine for me.

version: '3'

services:
    db:
        image: postgres:latest 
        container_name: postgres 
#        ports:
#            - 5433:5432 
        restart: unless-stopped 
        volumes:
            - /srv/dev-disk-by-uuid-e2c30baa-1378-4126-a5e0-f850fb3b9396/DOCKER/DATA/JOPLIN:/var/lib/postgresql/data # Make database files persistent. Otherwise data is lost when the container is destroyed.
        environment:
            - APP_PORT=22300 # port joplin-server is reachable at
            - POSTGRES_PASSWORD=mypassword123 #  database password
            - POSTGRES_USER=admin #  database user
            - POSTGRES_DB=joplin #  database name
    app:
        image: joplin/server:latest
        depends_on:
            - db
        ports:
            - "22300:22300" # Expose internal port to LAN
        restart: unless-stopped
        environment:
            - APP_BASE_URL=http://localhost:22300 # <- HERE
            - DB_CLIENT=pg
            - POSTGRES_PASSWORD=mypassword123 
            - POSTGRES_DATABASE=joplin 
            - POSTGRES_USER=admin
            - POSTGRES_PORT=5432 
            - POSTGRES_HOST=db

It fails authentication.

2021-09-17 07:08:37: App: Trying to connect to database...

2021-09-17 07:08:37: db: Could not connect. Will try again. password authentication failed for user "admin"

Is this because I need to create a database/user prior to running docker-compose (I assumed the compose file would do this for me)?

I think you ran the db container earlier with different user/password and now the db configuration is persisted thanks to this volume. It’s not enough to just remove the db container, you must remove volume as well to clean all data - https://documentation.portainer.io/v2.0/volumes/delete/.

1 Like

This seems to have solved it. Thanks a lot for the help!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.