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 solve mounting error when running docker?
  • How to write a long command within dockerfile?
  • How to delete a docker image in dockerhub with a particular tag or set of tags using CLI?
  • Mongodb won't start in Docker container when remote-mounting a volume from host
  • Not receiving UDP traffic on port exposed in Docker container running on Docker for Windows. How to debug?
  • How to get git repo current tag in Dockerfile during automated build in docker hub
  • 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.

  • set docker container env from daemon configuration file
  • SQL Server instance string connection in Linux Docker
  • Issue with running RabbitMQ in Python using Pika inside Docker container
  • Docker terminal on windows 10: does clipboard work?
  • How to upgrade npm to npm@5 on the latest node docker image?
  • docker container: add symlink to /Users/www/[project] in /var/www to access and serve local files
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.