title: Docker-compose command doesn't override Dockerfile CMD
body: <p><a href="https://docs.docker.com/compose/compose-file/#command" rel="noreferrer">Docker-compose reference</a> says:</p>
  <blockquote>
  <p>command</p>
  <p>Override the default command.</p>
  </blockquote>
  <p><strong>My Dockerfile</strong></p>
  <pre><code>FROM adoptopenjdk/maven-openjdk8
  
  RUN mkdir /config
  
  COPY /src/main/resources/application.properties /config/application.properties
  COPY /src/main/resources/logback.xml /config/logback.xml
  
  # copy wait-for-it-sh tool to sync container starting
  COPY wait-for-it.sh /
  RUN chmod +x /wait-for-it.sh
  
  VOLUME /tmp
  
  ADD target/my-svc-1.jar app.jar
  
  RUN sh -c 'touch /app.jar'
  
  ENV JAVA_OPTS=&quot;&quot;
  
  CMD [ &quot;sh&quot;, &quot;-c&quot;, &quot;java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar&quot; ]
  </code></pre>
  <p><strong>Interesting part of my docker-compose.yml</strong></p>
  <pre><code>version: '3'
  
  services:
    ..
    my-svc:
      container_name: my-svc-container
      build:
        context: ./my-svc-folder
        dockerfile: Dockerfile
      ports:
        - &quot;9100:9100&quot;
        - &quot;5005:5005&quot;
      depends_on:
        - db
      command: [&quot;./wait-for-it.sh&quot;, &quot;my-svc-dbserver:3306&quot;, &quot;--&quot;, &quot;sh&quot;, &quot;-c&quot;, &quot;java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 -jar /app.jar&quot;]
    ...
  </code></pre>
  <p>Output of docker-compose build:</p>
  <pre><code>Building my-svc
  Step 1/11 : FROM adoptopenjdk/maven-openjdk8
   ---&gt; b3ad935008a1
  Step 2/11 : RUN mkdir /config
   ---&gt; Using cache
   ---&gt; 5db347c13050
  Step 3/11 : COPY /src/main/resources/application.properties /config/application.properties
   ---&gt; Using cache
   ---&gt; ade3653a018a
  Step 4/11 : COPY /src/main/resources/logback.xml /config/logback.xml
   ---&gt; Using cache
   ---&gt; 94277fd95be1
  Step 5/11 : COPY wait-for-it.sh /
   ---&gt; Using cache
   ---&gt; 80ac64c7c994
  Step 6/11 : RUN chmod +x /wait-for-it.sh
   ---&gt; Using cache
   ---&gt; 1a0c99bc10ad
  Step 7/11 : VOLUME /tmp
   ---&gt; Using cache
   ---&gt; 81864f3c9fda
  Step 8/11 : ADD target/my-svc-1.jar app.jar
   ---&gt; Using cache
   ---&gt; 56cc5c149e37
  Step 9/11 : RUN sh -c 'touch /app.jar'
   ---&gt; Using cache
   ---&gt; 9db3f5d983cc
  Step 10/11 : ENV JAVA_OPTS=&quot;&quot;
   ---&gt; Using cache
   ---&gt; a5c4828b6539
  Step 11/11 : CMD [ &quot;sh&quot;, &quot;-c&quot;, &quot;java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar&quot; ]
   ---&gt; Using cache
   ---&gt; cb1fd876d8d6
  Successfully built cb1fd876d8d6
  Successfully tagged src_my-svc:latest
  </code></pre>
  <p>So, the last step is shown as
  <code>CMD [ &quot;sh&quot;, &quot;-c&quot;, &quot;java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar&quot; ]</code>, the one that is in Dockerfile instead of the one in docker-compose.</p>
  <p>What am I missing here?</p>