v0.39.0.1 / Troubleshooting Guide / Docker

While Docker simplifies a lot of aspects of running Metabase, there are a number of potential pitfalls to keep in mind.

Metabase provides an official Docker image via Dockerhub that can be used for deployments on any system that is running Docker. If you’re trying to upgrade your Metabase version on Docker, check out these upgrading instructions. Launching Metabase on a new container.

If you are having issues with Metabase under Docker, we recommend going through the troubleshooting process below. Then look below for details about the specific issue you’ve found.

  • Metabase provides an official Docker image via Dockerhub that can be used for deployments on any system that is running Docker. Here’s a one-liner that will start a container running Metabase. Docker run -d -p 3000:3000 -name metabase metabase/metabase. Head over to our documentation for more detailed information about running on Docker!
  • Advanced data processing, analysis, and visualization tools for Python & R. Anaconda, Inc. (formerly Continuum Analytics, Inc.).
  • If you have any further issues, questions, or would like some assistance checking on this or anything else, please reach out to us from your my.hivelocity.net account and provide your server credentials within the encrypted field for the best possible security and support.
  • When visualization returns null (No results), then UI becomes broken ; Upgrading. You can download a.jar of the release, or get the latest on Docker.

Troubleshooting Process

  1. Check that the container is running
  2. Check that the server is running inside the container
  3. Check whether Metabase is using the correct application database
  4. Check that you can connect to the Docker host on the Metabase port
  5. Check that you can connect to the container from the Docker host
  6. Check that you can connect to the server from within the container

Specific Problems

Metabase container exits without starting the server

Run docker ps to see if the Metabase container is currently running. If it is move on to the next step.

If docker ps does not show the running container, then list the stopped containers by running:

docker ps -a | grep metabase/metabase

And look for the container that exited most recently. Note the container ID.Look at that container’s logs with:

Docker logs CONTAINER_ID

Metabase Container is running but the Server is not

How to detect this:

Run docker ps to make sure the container is running

The server should be logging to the Docker container logs. Check this by running:

docker logs CONTAINER_NAME

You should see a line like this at the beginning:

and eventually:

If you see the below lines:

How to fix this:

Check this for errors about connecting to the application database.Watch the logs to see if Metabase is still being started:

Docker logs -f CONTAINER_ID

will let you see the logs as they are printed.

If the container is being killed before it finished starting it could be a health check timeout in the orchestration service used to start the container, such as Docker Cloud, or Elastic Beanstalk.

If the container is not being killed from the outside, and is failing to start anyway, this problem is probably not specific to Docker. If you are using a Metabase-supplied image, you should open a GitHub issue.

Not connecting to a remote application database

How to detect this:

If this is a new Metabase instance, then the database you specified via the environment variables will be empty. If this is an existing Metabase instance with incorrect environment parameters, the server will create a new H2 embedded database to use for application data and you’ll see lines similar to these:

How to fix this:

Double check you are passing environments to Docker in the correct way.You can list the environment variables for a container with this command:

docker inspect some-postgres -f '{{ .Config.Env }}'

The Metabase server isn’t able to connect to a MySQL or PostgreSQL database

How to detect this:

The logs for the Docker container return an error message after the “Verifying Database Connection” line.

How to fix this:

Try to connect with mysql or psql commands with the connection string parameters you are passing in via the environment variables.

If you can’t connect to the database, the problem is due to either the credentials or connectivity. Verify that the credentials are correct. If you are able to log in with those credentials from another machine then try to make the same connection from the host running the Docker container.

One easy way to run this is to use Docker to start a container that has the appropriate client for your database. For Postgres this would look like:

docker run --name postgres-client --rm -ti --entrypoint /bin/bash postgres

Then from within that container try connecting to the database host using the client command in the container such as psql. If you are able to connect from another container on the same host, then try making that connection from within the Metabase Docker container itself:

docker exec -ti container-name bash

And try to connect to the database host using the nc command and check if the connection can be opened:

nc -v your-db-host 5432

This will make it clear if this is a network or authentication problem.

The Metabase application database is not being persisted

How to detect this:

Metabase Docker Environment Variables

This occurs if you get the Setup screen every time you start the application. The most common root cause is not giving the Docker container a persistent filesystem mount to put the application database in.

How to fix this:

Make sure you are giving the container a persistent volume

The internal port isn’t being remapped correctly

How to detect this:

Run docker ps and look at the port mappingRun curl http://localhost:port-number-here/api/health. This should return a response with a JSON response like:

How to fix this:

Make sure to include a -p 3000:3000 or similar remapping in the docker run command you execute to start the Metabase container image.

Metabase can’t write or read to/from a file or directory

How to detect this:

A message in the logs will clearly indicate an IOError/Permission denied from Java, or errors from SQLite with the org.sqlite.core.NativeDB._open_utf8 form.

How to fix this:

Ensure that the user who is running Metabase has permission to read and write to the file or directory:

  • If you are running Metabase as a JAR file in your local machine or server, check the user who is running the Java process.
  • If you’re running Metabase from the Docker container, make sure you’re using the /metabase.db directory.

If you’re running Metabase from the JAR in any *nix (Unix like) operating system, in order to see which user is running Metabase, you have to open a terminal and type ps -uA | grep metabase.

Helpful tidbits

How to get to the shell in the Metabase container

docker exec -ti CONTAINER_NAME bash

How to get the logs for the Metabase container

docker logs -f CONTAINER_NAME

v0.39.0.1 / Operations Guide / Running Metabase on Docker

Metabase provides an official Docker image via Dockerhub that can be used for deployments on any system that is running Docker.

If you’re trying to upgrade your Metabase version on Docker, check out these upgrading instructions.

Launching Metabase on a new container

Here’s a quick one-liner to get you off the ground (please note, we recommend further configuration for production deployments below):

This will launch a Metabase server on port 3000 by default. You can use docker logs -f metabase to follow the rest of the initialization progress. Once the Metabase startup completes you can access the app at localhost:3000

Since Docker containers have their own ports and we just map them to the system ports as needed it’s easy to move Metabase onto a different system port if you wish. For example running Metabase on port 12345:

Mounting a mapped file storage volume

In its default configuration Metabase uses the local filesystem to run an H2 embedded database to store its own application data. The end result is that your Metabase application data will be on disk inside your container and lost if you ever remove the container.

To persist your data outside of the container and make it available for use between container launches we can mount a local file path inside our container.

Now when you launch your container we are telling Metabase to use the database file at ~/metabase-data/metabase.db instead of its default location and we are mounting that folder from our local filesystem into the container.

Getting your config back if you stopped your container

If you have previously run and configured your Metabase using the local Database and then stopped the container, your data will still be there unless you deleted the container with the docker rm command. To recover your previous configuration:

  1. Find the stopped container using the docker ps -a command.It will look something like this:

Once you have identified the stopped container with your configuration in it, save the container ID from the left most column for the next step.

  1. Use docker commit to create a new custom docker image from the stopped container containing your configuration.
  1. Run your new image using docker run to get up and running again.

    Hopefully you have your previously configured Metabase Installation back. If it’s not the one you expected try a different stopped container and do these steps again.

Metabase docker compose

Using Postgres as the Metabase application database

If you are ready to completely move off the H2 embedded database for running Metabase and prefer to use Postgres we’ve got that covered too.

In this scenario all you need to do is make sure you launch Metabase with the correct environment variables containing your Postgres database connection details and you’re all set. For example:

Keep in mind that Metabase will be connecting from within your docker container, so make sure that either you’re using a fully qualified hostname or that you’ve set a proper entry in your container’s /etc/hosts file.

Migrating from H2 to Postgres as the Metabase application database

For general information, see instructions for migrating from H2 to MySQL or Postgres.

To migrate an existing Metabase container from an H2 application database to another database container (e.g. Postgres, MySQL), there are a few considerations to keep in mind:

  • The target database container must be accessible (i.e. on an available network)
  • The target database container must be supported (e.g. MySQL, Postgres)
  • The existing H2 database should be mapped outside the running container

The migration process involves 2 main steps:

  1. Stop the existing Metabase container
  2. Run a new, temporary Metabase container to perform the migration

Using a Postgres container as the target, here’s an example invocation:

To further explain the example: in addition to specifying the target database connection details, set the MB_DB_FILE environment variable for the source H2 database location, and pass the argument load-from-h2 to begin migrating.

Setting the Java Timezone

It’s best to set your Java timezone to match the timezone you’d like all your reports to come in. You can do this by simply specifying the JAVA_TIMEZONE environment variable which is picked up by the Metabase launch script. For example:

Additional custom settings

While running Metabase on docker you can use any of the custom settings from Customizing the Metabase Jetty Webserver by setting environment variables on your docker run command.

In addition to the standard custom settings there are two docker specific environment variables MUID and MGID which are used to set the user and group IDs used by metabase when running in a docker container. These settings make it possible to match file permissions when files, such as the application database, are shared between the host and the container.

Here’s how to use a database file, owned by your account, that is stored in your home directory:

Now that you’ve installed Metabase, it’s time to set it up and connect it to your database.

Copying the application database

If you forgot to configure to the application database, it will be located at /metabase.db/metabase.db.mv.db in the container. You can copy this whole directory out of the container using the following command (replacing CONTAINER_ID with the actual container ID or name, metabase if you named the container):

Metabase Install

The DB contents will be left in a directory named metabase.db.Note that some older versions of metabase stored their db in a different default location.

Fixing OutOfMemoryErrors in some hosted environments

On some hosts Metabase can fail to start with an error message like:

If that happens, you’ll need to set a JVM option to manually configure the maximum amount of memory the JVM uses for the heap. Referto these instructions for details on how to do that.

Adding external dependencies or plugins

To add external dependency JAR files such as the Oracle or Vertica JDBC drivers or 3rd-party Metabase drivers, you will need to create a plugins directory in your host system and bind it so it is available to Metabase as the path /plugins using either --mount or -v/--volume. For example, if you have a directory named /path/to/plugins on your host system, you can make its contents available to Metabase using the --mount option as follows:

Note that Metabase will use this directory to extract plugins bundled with the default Metabase distribution (such as drivers for various databases such as SQLite), thus it must be readable and writable by Docker.

Metabase Github

Use Docker Secrets to hide the sensitive parameters

Docker Metabase

In order to keep your connection parameters hidden from plain sight, you can use Docker Secrets to put all parameters in files so Docker can read and load them in memory before the container is started.

This is an example of a docker-compose.yml file to start a Metabase container with secrets to connect to a PostgreSQL database. Create 2 files (db_user.txt and db_password.txt) in the same directory as this yml and fill them with any username and a secure password: