0

I have a docker compose file as follows:

    version: '3'
    services:
    prisma:
        image: prismagraphql/prisma:1.34.10
        restart: always
        ports:
        - '4466:4466'
        environment:
        PRISMA_CONFIG: |
            port: 4466
            databases:
            default:
                connector: mysql
                host: test.mysql.database.azure.com
                database: default@default
                user: rie@dak-prod
                password: ak123#$
                ssl: false
                rawAccess: true
                port: '3306'
                migrations: true

When I try the command docker-compose up -d the command fails with an error :

ERROR: Invalid interpolation format for "environment" option in service "prisma": "port: 4466
databases:
default:
    connector: mysql
    host: est.mysql.database.azure.com
    database: default@default
    user: rie@dak-prod
    password: ak123#$
    ssl: false
    rawAccess: true
    port: '3306'
    migrations: true
"

The reason that I have identified is the # in the password. If # is not there, it does not throw up this error. How can I escape (use) hash the the docker compose file?

Pierre B.
  • 11,612
  • 1
  • 37
  • 58
Amanda
  • 2,013
  • 3
  • 24
  • 57

4 Answers4

4

I think the problem is not with a # but with a $ symbol.

You can use a $$ (double-dollar sign) when your configuration needs a literal dollar sign. This also prevents Compose from interpolating a value, so a $$ allows you to refer to environment variables that you don’t want processed by Compose.

So in your case ak123#$ must be written as ak123#$$

Reference documentation

Suhail Gupta
  • 22,386
  • 64
  • 200
  • 328
1

Quote your string to include special characters in yaml like the #, and escape the dollar sign using a second dollar sign to prevent docker-compose from expanding it:

password: "ak123#$$"
BMitch
  • 231,797
  • 42
  • 475
  • 450
0

Best way to use is base64 encode function. convert your password into base64 and try. should work.

Like this

echo "ak123#$" | base64

and whatever the output use as your password and more secure way

Dashrath Mundkar
  • 7,956
  • 2
  • 28
  • 42
0

Your docker-compose.yml have two issues:

You can use a $$ (double-dollar sign) when your configuration needs a literal dollar sign

  • PRISMA_CONFIG indentation under environment: is invalid, as PRISMA_CONFIG should be a subelement of environment

You should use something like:

    environment:
      # proper indentation to have PRISMA_CONFIG part of environment
      PRISMA_CONFIG: |
          port: 4466
          databases:
          default:
              connector: mysql
              host: test.mysql.database.azure.com
              database: default@default
              user: rie@dak-prod
              # double $ to have a literal '$'
              password: ak123#$$
              ssl: false
              rawAccess: true
              port: '3306'
              migrations: true
Pierre B.
  • 11,612
  • 1
  • 37
  • 58