Docker: set a multiline environment variable

Viewed 405

I want to run a container and also pass to it some env vars.

One of them is a GCP private (service account) key which is a multiline string, more or less in the following format:

{
  "type": "service_account",
  "project_id": "my-project",
  "private_key_id": "39dj4847dhcba0484hb",
  "private_key": "-----BEGIN PRIVATE KEY-----\nDDik499dkdm4n4849doidkdjm$90f9fkcm\n-----END PRIVATE KEY-----\n",
  "client_email": "something@my-project.iam.gserviceaccount.com",
  "client_id": "383748490382672627384745645363",
  "auth_uri": "https://accounts.google.com/o/oauth2/auth",
  "token_uri": "https://oauth2.googleapis.com/token",
  "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
  "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/somethingelse.gserviceaccount.com"
}

So I want to create a container by passing the above as the GOOGLE_APPLICATION_CREDENTIALS env var.

I assume the traditional docker run -e GOOGLE_APPLICATION_CREDENTIALS=(all of the above will either not work or will be cumbersome to add manually all the new line characters required.

How can I go about it?

P.S. I am aware of this discussion but it addresses the issue in the context of the Dockerfile

0 Answers
Related