Install Mathesar web server via Docker¶
Use our official Docker image: mathesar/mathesar-prod:latest
hosted on Docker Hub to run Mathesar.
Limitations
This installation procedure is intended for users who want to run a bare-bones version of the Mathesar web server.
It is assumed you already have a database server and services like a reverse proxy typically needed for running a production setup. If you don’t have those, please use the Docker Compose installation documentation.
Prerequisites¶
Operating System¶
You can install Mathesar using this method on Linux, MacOS, and Windows.
Access¶
You should have permission to run Docker containers on the system.
Software¶
You’ll need to install Docker v23+
Databases¶
Database for Mathesar’s internal usage¶
You’ll need to:
- Create a PostgreSQL database for Mathesar’s internal usage.
- Create a database user for Mathesar to use. The user should be a
SUPERUSER
, see PostgreSQL docs for more information. - Ensure that this database can accept network connections from the machine you’re installing Mathesar on.
- Have the following information for this database handy before installation:
- Database hostname
- Database port
- Database name
- Database username
- Database password
Databases connected to Mathesar’s UI¶
Have the following information for all databases you’d like to connect to Mathesar’s UI before installation:
- Database hostname
- Database port
- Database name
- Database username (should be a
SUPERUSER
, see above) - Database password
Database creation
Whenever the Docker container is started, we will attempt to create any databases in this list that don’t already exist. So you don’t need to ensure that they are created before installation.
Installation Steps¶
-
Run the Mathesar Docker Image
docker run \ --detach -e DJANGO_DATABASE_URL='<replace with a postgres connection string>' \ -e MATHESAR_DATABASES='(<unique_db_key>|<replace with a postgres connection array>)' \ -e SECRET_KEY='<replace with a 50 character string>' \ -e ALLOWED_HOSTS='.localhost, 127.0.0.1, [::1]' \ -v static:/code/static \ -v media:/code/media \ --name mathesar_service \ -p 8000:8000 \ --restart unless-stopped \ mathesar/mathesar-prod:latest
The above command creates a Docker container containing the Mathesar server running on the
localhost
and listening on port8000
. It also:- Passes configuration options as environment variables to the Docker container. Refer to Configuring Mathesar web server for setting the correct value to these configuration options and for additional configuration options. The configuration options used in the above command are:
DJANGO_DATABASE_URL
DJANGO_DATABASE_KEY
MATHESAR_DATABASES
SECRET_KEY
- Creates two named Docker volumes
static
for storing static assets like CSS, js filesmedia
for storing user-uploaded media files
- Sets the container name as
mathesar_service
using the--name
parameter, runs the container in a detached mode using the--detach
parameter, and binds the port8000
to thelocalhost
. Refer to Docker documentation for additional configuration options.
- Passes configuration options as environment variables to the Docker container. Refer to Configuring Mathesar web server for setting the correct value to these configuration options and for additional configuration options. The configuration options used in the above command are:
-
Verify if the Mathesar server is running successfully:
-
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.
Upgrading Mathesar¶
-
Stop your existing Mathesar container:
-
Remove the old Mathesar Image
-
Bump the image version in the
docker run
command you usually use to run your Mathesar and start up a brand-new container:
Uninstalling Mathesar¶
-
Remove the Mathesar container.
-
Remove the Mathesar Image
-
Remove volumes related to Mathesar
-
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.
-