stringdockerdocker-composeyamlquoting

Docker Compose mangling YAML, how do I see the YAML it renders?


My Docker Compose is acting up, starting from https://stackoverflow.com/a/30064175, I have something like:

services:
  stuff:
    image: alpine
    entrypoint: [ "/bin/sh", "-c" ]
    command: |
        export a=100 && \
        export b='f a' && \
        export c="a g" && \        
        echo "a = ${a} ; b = ${b} ; c = ${c}";

I've tried: command: >, and a large number of variants https://stackoverflow.com/a/21699210. I've tried with and without && with and without \.

Can I see what Docker Compose sees before it actually executes, i.e., after all the interpolation and other rendering?


Solution

  • Can I see what Docker Compose sees before it actually executes, i.e., after all the interpolation and other rendering?

    That looks like a job for docker compose config.

    From the docs:

    docker compose config renders the actual data model to be applied on the Docker Engine. It merges the Compose files set by -f flags, resolves variables in the Compose file, and expands short-notation into the canonical format.

    This also allows you to see the result of using extends and/or include.