Joplin Server Persistent Data with florider89/joplin-server docker image

@florider I've installed your version of the Docker Image because I thought it had persistent data in the Postgres container, however, it constantly seems to reset when we reboot the server.

Would you be able to offer any suggestion to make the data persistent?

Have you mounted a volume for PGData? See documentaton for PGDATA here: Docker Hub

I'm not the best with Docker, but I'm assuming it is mounted.

Here is the Docker Compose files;

version: '3'
services:
    app:
        environment:
            - APP_BASE_URL=http://domain.com:22300
            - APP_PORT=22300
            - POSTGRES_PASSWORD=joplin
            - POSTGRES_DATABASE=joplin
            - POSTGRES_USER=joplin 
            - POSTGRES_PORT=5432 
            - POSTGRES_HOST=db
            - DB_CLIENT=pg
        restart: unless-stopped
        image: florider89/joplin-server:2.2.7-beta
        ports:
            - "22300:22300"
    db:
        restart: unless-stopped
        image: postgres:13.1
        ports:
            - "5432:5432"
        volumes:
            - /foo/bar/joplin-data:/var/lib/postgresql/data
        environment:
            - POSTGRES_PASSWORD=joplin
            - POSTGRES_USER=joplin
            - POSTGRES_DB=joplin

Unless you have a directory called /foo/bar/joplin-data it is not mounted properly.

P.S.: You have to replace the first part (of the volume setting) with an existing directory on your host system.

1 Like

Ok, interesting... Let me check that.

@tessus @florider Actually once I started looking at the documentation it seems more difficult than I expected.

Would you guys know how this is done on Windows?

What is the problem under windows?

        volumes:
            - d:/foo/bar/joplin-data:/var/lib/postgresql/data

Let me try this.

Also for those following and for further references I'm also reviewing this article.

Yes this is a problem, mounting linux to windows permissions...

I can't offer any help here right now, the last time I had this i built my own images.
But running (linux) images with mounted volumes on windows has some problems (like performance and permissions) and with the Docker Desktop (Docker Desktop is not the same as Docker CE on linux!) variant for windows there are many more limitations.

Ok for future people here is what seems to have fixed it for me.

To recap this is for having Postgres Persistent Data on Windows.

First you need to run this command to create the volume;

docker volume create --name=pgdata

I'm really not sure where the data is stored unless it is in the Program Data folder for Docker, but it works when I deleted the container and ran docker compose up again.

Then use this docker-compose.yml fil which has the extra volume setting;

version: '3'
services:
    app:
        environment:
            - APP_BASE_URL=http://domain.com:22300
            - APP_PORT=22300
            - POSTGRES_PASSWORD=joplin
            - POSTGRES_DATABASE=joplin
            - POSTGRES_USER=joplin 
            - POSTGRES_PORT=5432 
            - POSTGRES_HOST=db
            - DB_CLIENT=pg
        restart: unless-stopped
        image: florider89/joplin-server:2.2.7-beta
        ports:
            - "3004:22300"
    db:
        restart: unless-stopped
        image: postgres:13.1
        ports:
            - "5432:5432"
        volumes:
            - pgdata:/var/lib/postgresql/data
        environment:
            - POSTGRES_PASSWORD=joplin
            - POSTGRES_USER=joplin
            - POSTGRES_DB=joplin
            
volumes:
  pgdata:
     external: true

@florider @JackGruber @tessus

Gentleman, thanks for your help.

I hope this helps other in the future.

1 Like

You'll have to check the Docker docs. On Posix (all but Windows) systems, named volumes are (by default) in /var/lib/docker/volumes/<volume_name>.

1 Like