Install Mathesar via Docker Compose¶
Prerequisites¶
Operating System¶
You can install Mathesar using this method on Linux, MacOS, and Windows.
Access¶
You should have root access to the machine you’re installing Mathesar on.
Software¶
You’ll need to install the following software before you install Mathesar:
- Docker v23+
- Docker Compose v2.10+
- If you’re installing on Windows:
- Ensure you have WSL installed
- Turn on Docker Desktop WSL 2, see Docker docs for more information
Domain (optional)¶
If you want Mathesar to be accessible over the internet, you’ll probably want to set up a domain or sub-domain to use. If you don’t need a domain, you can skip this section.
Before you start installation, ensure that the DNS for your sub-domain or domain is pointing to the machine that you’re installing Mathesar on.
Database (optional)¶
You can create a new PostgreSQL database while setting up Mathesar or use our UI to interact with an existing database. If you don’t have a database you want to connect to, you can skip this section.
To connect Mathesar to an existing database:
- The external database should be able to accept network connections from your Mathesar server.
- You’ll need to set up a database user for Mathesar to use. The user should be a
SUPERUSER
, see PostgreSQL docs for more information. - Have the following information handy before installation:
- Database hostname
- Database port
- Database name
- Database username
- Database password
See Connect to an existing database for more details.
Step-by-Step Guide¶
-
Navigate to a directory where you’d like to store your Mathesar configuration. We recommend
/etc/mathesar
, but it can be any directory. -
Download our docker-compose.yml, and .env.example files to the directory you’ve chosen.
-
Rename
.env.example
to.env
Your custom
.env
file will be used for setting configuration variables. -
Set up the database
- To use the default database server bundled with Mathesar, no additional steps are necessary. The database service will start along with the Mathesar web server.
- Alternatively, you can disable the default database server if you plan on using an existing database server.
-
Set up the web server.
-
Edit your
.env
file, making the following changes:- Add the Backend Configuration environment variables
- Customize the values of the environment variables to suit your needs.
Example
If you are using the default database container, your
.env
file should look something like this -
Start the Mathesar web server.
-
-
Set up the Caddy reverse proxy.
-
Edit your
.env
file, adding the Caddy Reverse Proxy environment variables. -
Start the Caddy reverse proxy
-
-
(Optional) Start the upgrade server to enable upgrading the docker image using the Mathesar UI.
-
Set up your user account
Mathesar is now installed! You can use it by visiting
localhost
or the domain you’ve set up.You’ll be prompted to set up an admin user account the first time you open Mathesar. Just follow the instructions on screen.
Starting and stopping Mathesar¶
The Mathesar server needs to be running for you to use Mathesar. If you restart your machine, you’ll need to start the server again.
-
Start Mathesar:
-
Stop Mathesar:
This stops all Mathesar Docker containers and releases their ports.
Note
If you customized the Mathesar configuration directory during installation, you’ll need to change /etc/mathesar
to your configuration directory.
Upgrading Mathesar¶
Upgrade from within Mathesar
You can also run the upgrade from within Mathesar by logging in as an admin user and navigating to “Administration” (in the top right menu) > “Software Update”
Manually upgrade Mathesar to the newest version using Watchtower:
Manually upgrade Mathesar to the newest version without using Watchtower:
Uninstalling Mathesar¶
-
Remove all Mathesar Docker images and containers.
-
Remove configuration files.
Note
If you customized the Mathesar configuration directory during installation, you’ll need to change
/etc/mathesar
to your configuration directory. -
Remove Mathesar internal schemas.
If you’d like to continue using your PostgreSQL database, you’ll need to remove the schemas created for Mathesar’s use during installation. You can remove them from the database as follows:
-
Connect to the database.
-
Delete the types schema.
Deleting this schema will also delete any database objects that depend on it. This should not be an issue if you don’t have any data using Mathesar’s custom data types.
-
Delete the function schemas.
-