Easily deploy Metabase using Docker container with this simple setup. It targets port 80, allowing you to access the Metabase instance directly through your IP address in a browser.
- Docker Compose installed on your system (see this tutorial)
- Create a directory called Metabase
mkdir metabase
cd metabase
- Create a ´docker-compose.yml´ file with the following content:
version: '3'
services:
metabase:
image: metabase/metabase:latest
ports:
- 80:3000
environment:
MB_DB_TYPE: postgres
MB_DB_DBNAME: metabase
MB_DB_PORT: 5432
MB_DB_USER: metabase
MB_DB_PASS: metabase
MB_DB_HOST: postgres
postgres:
image: postgres:latest
environment:
POSTGRES_USER: metabase
POSTGRES_DB: metabase
POSTGRES_PASSWORD: metabase
volumes:
- ./pg:/var/lib/postgresql/data
- Pull the required Docker image
docker-compose pull
- Start the Metabase and PostgreSQL containers:
docker-compose up
From time to time, Metabase releases new versions with feature improvements, bug fixes, or security patches. It's a good practice to keep your Metabase instance up-to-date. Here are the steps to update Metabase:
-
Stop Nginx Service (if running):
Before making any changes, especially if you have set up HTTPS as shown above, ensure the Nginx service is stopped.
sudo systemctl stop nginx
-
Stop Current Docker Services:
Ensure your Metabase and PostgreSQL services are stopped before updating.
docker-compose down
-
Pull the Latest Metabase Image:
This step fetches the latest version of the Metabase Docker image.
docker pull metabase/metabase:latest
-
Start Nginx Service:
If you're using Nginx for SSL termination, start it back up.
sudo systemctl start nginx
-
Restart Docker Services:
Now, with the updated Metabase image, start the services again.
docker-compose up
- Stop the Docker Compose services:
docker-compose down
- Update the package list and install Certbot:
sudo apt-get update
sudo apt install -y certbot python3-certbot-apache
- Generate SSL certificates using Certbot:
sudo certbot certonly --standalone -d example.com --preferred-challenges http --agree-tos -m [email protected] --keep-until-expiring
- Copy the generated certificates to your project directory:
sudo cp -r /etc/letsencrypt/live/example.com ./certs
sudo chown -R $USER:$USER ./certs
- Install Nginx:
sudo apt update
sudo apt install nginx
- Create a new Nginx configuration file:
sudo touch /etc/nginx/sites-available/example.com
- Add the following configuration to the file, replacing
example.com
with your domain andYOUR_APP_IP:3000
with the IP and port of your application:
server {
listen 80;
server_name example.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name example.com;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
location / {
proxy_pass http://YOUR_APP_IP:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
- Create a symbolic link to the
sites-enabled
directory:
sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
- Test the Nginx configuration:
sudo nginx -t
- Restart Nginx:
sudo systemctl restart nginx
- Start the Docker Compose services:
docker-compose up