Google Cloud App Engine

Install Metabase on Google Cloud with Docker – App Engine

Disclosure: This post may contain affiliate links, which means we may receive a commission if you click a link and purchase something that we recommended.

Pinterest LinkedIn Tumblr

Install Metabase on Google Cloud with Docker on Google App Engine. In this tutorial you are going to learn how to install Metabase and connect it with Cloud SQL with CloudSQL proxy.

This guide demonstrates how to install Java using Docker in App Engine Flexible Environment with app.yaml and Dockerfile which is easily scalable.


  1. Google Cloud account with billing activated.
  2. Cloud SQL setup as described here Cloud SQL Second Generation Instance.
  3. Enable Cloud SQL and Cloud SQL Admin API.
  4. Install GCloud SDK in your local computer.

Enable APIs and Create New Service account

Go to APIs and Services and click Enable APIs and Services and enable Cloud SQL API and Cloud SQL Admin API

Go to IAM & Admin >> Service accounts and click Create service account.

In step 1

Enter Service account Name.

Click Create.

In step 2

Select Role.

Cloud SQL >> Cloud SQL Admin
Project >> Editor

Click Continue.

In step 3

Click Create Key.

Choose Key type as JSON

Click Create.

Create Cloud SQL Instance

Follow this tutorial to create a new Cloud SQL Second Generation Instance.

Once you have created a user and a database you can proceed to set up the yaml file and Docker file in the local computer.

Setup Cloud SDK

Once you have installed the cloud SDK, run the below command to configure it and choose the project to deploy the Metabase.

Open command prompt or terminal in your local computer and run the following the command.

gcloud init

Follow the onscreen instructions to configure it.

Create Yaml File for Metabase

Create a new directory in your computer named metabase

Open your favorite editor and create a file named app.yaml inside the metabase directory.

Copy the below code and add this in your app.yaml file.

runtime: custom
env: flex

   instances: 1

   MB_DB_TYPE: mysql
   MB_DB_DBNAME: cloudsql_db_name
   MB_DB_USER: cloudsql_user_name
   MB_DB_PASS: cloudsql_password

   cloud_sql_instances: cloudsql_connection_name

Replace the cloudsql_db_name, cloudsql_user_name, cloudsql_password, and cloudsql_connection_name with the values of your Cloud SQL instance.

Save your file.

Create Dockerfile for Metabase

Create a new file in the same metabase directory and name it as Dockerfile

Copy the below code and add this in your Dockerfile file.



ENV METABASE_SQL_INSTANCE cloudsql_connection_name
ENV JAVA_OPTS "-XX:+IgnoreUnrecognizedVMOptions -Dfile.encoding=UTF-8 --add-opens=java.base/ --add-modules=java.xml.bind"

ADD ./cloud_sql_proxy
ADD ./metabase.jar

RUN chmod +x ./cloud_sql_proxy

CMD ./cloud_sql_proxy -instances=$METABASE_SQL_INSTANCE=tcp:$MB_DB_PORT & java -jar ./metabase.jar

Replace the cloudsql_connection_name with your Cloud SQL instance connection name.

Save the file.

Deploy Metabase to App Engine

Open terminal in the metabase directory.

Run the following command to deploy Metabase to App Engine.

gcloud app deploy

Now, Metabase will be installed on Google App Engine and connected with Cloud SQL.

Once the deployment is completed you will get the url to view your application on the browser.

Install Metabase on Google Cloud with Docker - App Engine


Now you have learned how to deploy Metabase on Google App Engine Flexible environment.


  1. hi thank you for this post,

    I am getting this error, is there something that I might have not set?

    ERROR metabase.core :: Metabase Initialization FAILED
    java.lang.Exception: Connection to refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.

    • This is simply that App Engine was unable to connect metabase to the backend db. You’ve ensured the app engine service account has Cloud SQL Client or Admin role? And that there is a db in your sql instance named metabase, with the matching user and password combination?

    • This sounds like the App Engine service is not being properly hosted, perhaps you didn’t expose port 8080 in the dockerfile, or you didn’t include it as an ENV variable in the app.yaml like so (the author didn’t include this bit, not sure why, but it seems essential):

      MB_DB_DBNAME: ‘metabase’
      MB_DB_TYPE: ”
      MB_DB_HOST: ‘’
      MB_DB_PORT: ‘3306’ or ‘5432’
      MB_DB_USER: ‘metabase’
      MB_DB_PASS: ‘metabase’
      MB_JETTY_PORT: ‘8080’

      • Done, but still I got the 502 message, I’m installing the latest version of Metabase, using Postgres.

  2. Installed it all correctly some time ago but I’m not that familiar with GCP and not sure how to update to the latest version of metabase.

Write A Comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.