Running Cloud SQL proxy with docker-compose
Create a service account key file and name it serviceAccount.json
right next to your docker-compose.yml
file. For this example, my GCP project's id is project-ac42
, chosen region is us-central1
, and my Cloud SQL instance's name is playground-cloud-sql-instance
version: "3.8"
services:
proxy:
container_name: "cloud-sql-proxy"
image: gcr.io/cloudsql-docker/gce-proxy:1.16
volumes:
- ./serviceAccount.json:/config
ports:
- 127.0.0.1:5432:5432
command: "/cloud_sql_proxy -instances=playground-ace42:us-central1:playground-cloud-sql-instance=tcp:0.0.0.0:5432 -credential_file=/config"