How to Fix the Invalid Interpolation Format Error in Docker Compose
We run into a strange error when we added a new environment variable to our Docker Compose file:
ERROR: Invalid interpolation format for "environment" option in service "api": "MY_KEY=Abc$5"
Our docker-compose.yaml file looks like this:
The problem is the $ in the value of the environment variable MY_KEY. Docker allows a lot of flexibility in its configuration files. One way to do that is to use variables. Unfortunately, in our case the $ is just a $ and not an indicator for a variable. It is basically the same problem we had a few years ago with DbUp.
We can escape the $ sign by using two $$ to prevent the variable substitution:
With this change we can run docker-compose without any errors. Inside the container, our variable has the right number of $:
