Creating a Julia docker container for use on Google Cloud Run

Author

George Metzger

Published

February 23, 2025

I ran into several issues getting a Julia docker container up and running on Google Cloud so I decided to document the steps for others. Apart from the Julia Dash containerization, the rest of the steps are language agnostic.

Julia/Dash

First, you will need to replace your run_server() string in your app.jl with this:

port = parse(Int, get(ENV, "PORT", "8050"))
run_server(app, "0.0.0.0", port; debug = false)

Your Dockerfile should look like this:

FROM julia:latest

WORKDIR /app

COPY . .

RUN julia -e 'using Pkg; Pkg.add(["<add packages>"])'
RUN julia -e 'using Pkg; Pkg.add(url="<add github packages>")'

EXPOSE 8050

ENV PORT 8050

CMD ["julia", "--project=.", "app.jl"]

Docker

Create the docker container for your app.

docker build -t <your-tag> .

When creating Docker containers on ARM Macs (M chips) you need to adjust your docker build command so they are built for the architecture they will be running on.

docker buildx build -t <your-tag> --platform linux/amd64 .

Google Cloud Run

You will need to install and configure Google Cloud CLI. If you don’t already have Homebrew installed get that first from https://brew.sh/.

brew install --cask google-cloud-sdk
gcloud init
gcloud auth configure-docker

On Google Cloud you will need to enable its Artifact Registry by navigating to it in the console.

Create a GCR tag and push to Google Cloud.

docker tag <docker-image> gcr.io/<project-id>/<docker-image>
docker push gcr.io/<project-id>/<docker-image>

After it’s been pushed you can deploy your container on Cloud Run.