This document provides a comprehensive guide on deploying Memos with Docker, including installation and upgrading instructions.
Prerequisites
Before proceeding with Memos installation, ensure you meet the following prerequisites:
- A server with Docker installed: Memos is designed to be self-hosted with Docker.
Docker Run
To set up Memos using docker run
, execute the following one command to start Memos:
docker run -d \ --init \ --name memos \ --publish 5230:5230 \ --volume ~/.memos/:/var/opt/memos \ ghcr.io/usememos/memos:latest
This command will launch Memos in the background, exposing it on port 5230
. Data will be stored in the ~/.memos/
directory. You can customize the port and the data directory path as needed.
Parameter Options
mode (-m, --mode):
- Values: "prod" or "dev"
- Default: "prod"
- Purpose: Sets the mode of the server, influencing its runtime behavior. Options include production ("prod"), development ("dev").
addr (-a, --addr):
- Value: String representing the server address.
- Default: Empty string.
- Purpose: Specifies the address on which the server will listen for incoming connections.
port (-p, --port):
- Value: Integer representing the server port.
- Default: 8081.
- Purpose: Sets the port on which the server will be accessible.
data (-d, --data):
- Value: String representing the data directory.
- Default: Empty string.
- Purpose: Specifies the directory where Memos will store its data.
driver (--driver):
- Value: String representing the database driver. We currently support "sqlite" and "mysql".
- Default: "sqlite"
- Purpose: Sets the database driver to be used by Memos.
dsn (--dsn):
- Value: String representing the database source name. Only applicable when using the MySQL driver.
- Default: Empty string.
- Purpose: Specifies the database source name (DSN) for connecting to the database.
metric (--metric):
- Value: Boolean (true/false).
- Default: true.
- Purpose: Enables or disables metric collection. When enabled, Memos collects metrics for analysis. See more with our Privacy Policy pages.
Docker Compose
To deploy Memos using docker compose
, create a docker-compose.yml
file with the following configuration:
version: "3.0" services: memos: image: ghcr.io/usememos/memos:latest container_name: memos volumes: - ~/.memos/:/var/opt/memos ports: - 5230:5230
Now, execute docker-compose up -d
to initiate Memos. While editing the port and data directory is possible, only modify the first port (e.g., 8081:5230
) to specify an alternative port. The second port designates the port Memos is listening on inside the container. The same principle applies to directory paths, where the first path represents the location on your host system, and the second path signifies the directory inside the container.
Upgrading Memos
To upgrade Memos to the latest version, perform the following steps:
First, stop and remove the old container:
docker stop memos && docker rm memos
Although optional, it's advisable to back up your database:
cp -r ~/.memos/memos_prod.db ~/.memos/memos_prod.db.bak
Next, pull the latest memos image:
docker pull ghcr.io/usememos/memos:latest
Finally, initiate Memos by following the steps outlined in the Docker Run section. Your upgraded Memos instance will now be up and running with the latest enhancements and features.