1. Get the docker sample configuration file.
$wget https://raw.githubusercontent.com/laurent22/joplin/dev/.env-sample $move .env-sample .env $vim .env
2. The example configuration will like below:
#============================================================================= # PRODUCTION CONFIG EXAMPLE # ----------------------------------------------------------------------------- # By default it will use SQLite, but that's mostly to test and evaluate the # server. So you'll want to specify db connection settings to use Postgres. #============================================================================= # # APP_BASE_URL=https://example.com/joplin # APP_PORT=22300 # # DB_CLIENT=pg # POSTGRES_PASSWORD=joplin # POSTGRES_DATABASE=joplin # POSTGRES_USER=joplin # POSTGRES_PORT=5432 # POSTGRES_HOST=localhost #============================================================================= # DEV CONFIG EXAMPLE # ----------------------------------------------------------------------------- # Example of local config, for development. In dev mode, you would usually use # SQLite so database settings are not needed. #============================================================================= # # APP_BASE_URL=http://localhost:22300 # APP_PORT=22300
3. If normal usage, use PRODUCTION section.
PS:If only for debug or demo, use DEV section.
APP_BASE_URL=https://example.com/joplin APP_PORT=22300 DB_CLIENT=pg POSTGRES_PASSWORD=joplin POSTGRES_DATABASE=joplin POSTGRES_USER=joplin POSTGRES_PORT=5432 POSTGRES_HOST=localhost
PS. Please change the POSTGRES_PASSWORD with you want.
4. But, even use the docker, this docker will connect to your localhost DB. So, you must manually create the DB on your localhost.
$sudo -u postgres psql
When you entry into the PostgreSQL console, please type the below command:
PS. The PASSWORD must equal the POSTGRES_PASSWORD.
CREATE DATABASE joplin; CREATE USER joplin WITH PASSWORD 'yourpassword'; ALTER ROLE joplin SET client_encoding TO 'utf8'; ALTER ROLE joplin SET default_transaction_isolation TO 'read committed'; ALTER ROLE joplin SET timezone TO 'UTC'; GRANT ALL PRIVILEGES ON DATABASE joplin TO joplin; \q
5. Run the docker.
$docker run --net=host --add-host=host.docker.internal:127.0.0.1 --env-file .env -p 22300:22300 joplin/server:latest
6. You can visit the local host on browser.
http://localhost:22300/
7. The default login setting:
Default username: admin@localhost
Default password: admin
8. You can create the bash file to easily run the docker:
#!/bin/bash docker pull joplin/server:latest docker stop joplin docker rm joplin docker run -d --restart unless-stopped --name joplin \ --net=host \ --add-host=host.docker.internal:127.0.0.1 \ --env-file .env \ -p 22300:22300 \ joplin/server:latest
9. Reference:
(1) https://hub.docker.com/r/joplin/server
(2) https://netivism.com.tw/blog/512
(3) https://raw.githubusercontent.com/laurent22/joplin/dev/.env-sample