Using ENTRYPOINT in a Dockerfile makes the base image's CMD be ignored

It looks as if when my Dockerfile uses an ENTRYPOINT script, its base image’s CMD is ignored. Could anybody tell me why and/or where in the doc this behavior is explained?

Here is an example with a Dockerfile extending the official php:7.0-fpm image (which uses CMD ["php-fpm"]). In the entrypoint script, I expect the $@ variable to contain the string php-fpm but it’s empty.

  • How to create windows docker image with VS test agents?
  • Unable to execute shell script with parameter from Dockerfile
  • docker run complains file not found
  • Linking multiple docker containers to one container with alias localhost using docker-compose
  • Deploying docker-compose containers
  • What's the simplest mac docker setup for archival purposes?
  • marc@imac-marc:/opt/php-docker$ cat Dockerfile-php
    FROM php:7.0-fpm
    COPY utils/entrypoint.sh /usr/local/bin/
    RUN chmod +x /usr/local/bin/entrypoint.sh
    ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
    
    marc@imac-marc:/opt/php-docker$ cat utils/entrypoint.sh 
    #!/usr/bin/env bash
    echo "CMD = $@"
    
    marc@imac-marc:/opt/php-docker$ docker build -t me:myImage -f Dockerfile-php .
    Sending build context to Docker daemon   276 kB
    Step 1 : FROM php:7.0-fpm
     ---> d66add11c05d
    Step 2 : COPY utils/entrypoint.sh /usr/local/bin/
     ---> a62ef60a202b
    Removing intermediate container 20bd7782844e
    Step 3 : RUN chmod +x /usr/local/bin/entrypoint.sh
     ---> Running in 27af4ffbd6c0
     ---> 77fba35c804d
    Removing intermediate container 27af4ffbd6c0
    Step 4 : ENTRYPOINT /usr/local/bin/entrypoint.sh
     ---> Running in 6779b16542ec
     ---> 326970218669
    Removing intermediate container 6779b16542ec
    Successfully built 326970218669
    
    marc@imac-marc:/opt/php-docker$ docker run me:myImage
    CMD = 
    

    If I add CMD ["php-fpm"] to my Dockerfile, it works as expected.

  • Windows server 2008 base image for docker
  • How do the Docker Swarm Agents tell their IP to the Swarm Manager back?
  • Is it possible to let ansible print each statement?
  • what's the data's meaning collected by cadvisor?
  • Using docker and hosts file
  • How to view log output using docker-compose run?
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.