title: Use inline comments in docker-compose command
body: <p>In my <code>docker-compose.yml</code> I need to use a very long <code>command</code>, and I want to document it. This is not easily done, but I have a workaround that's ALMOST working.</p>
  
  <pre><code>foo:                                    # valid comment
    image: foo:latest                     # valid comment
    command: &gt;
             printf '
             something                    # explanation for this command
             --arg                        # explanation for this switch
             --a                          # explanation
             --b hello
             -c                           # this does...
             --d spam                     # don't use this when...
             #some notes
             --e ham                      # hmmm
             --eggs                       # explanation
             ' |grep -v ^[[:space:]]*$ |grep -v ^# |cut -d# -f1   # valid comment
    restart: always                       # valid comment
  </code></pre>
  
  <p>So every command and switch can be commented.</p>
  
  <p>The bash:</p>
  
  <ul>
  <li><code>printf ' ... '</code> prints all the stuff as text, to be run as a command</li>
  <li><code>grep -v ^[[:space:]]*$</code> ignores the first empty line</li>
  <li><code>grep -v ^#</code> ignores comment lines</li>
  <li><code>cut -d# -f1</code> strips inline comments from each line</li>
  </ul>
  
  <p><em>This trick works perfectly in the shell !</em></p>
  
  <p>However <code>docker-compose up</code> says:</p>
  
  <blockquote>
    <p>ERROR: Invalid interpolation format for "command" option in service "foo": "printf ' something ...</p>
  </blockquote>
  
  <p>If I escape the <code>$</code> as <code>$$</code> it says:</p>
  
  <blockquote>
    <p>ERROR: for foo  No closing quotation</p>
  </blockquote>
  
  <p>How can I get this to work?</p>