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.

  • CPP Rest SDK http_listener throws exception in nano server (in a Docker container)
  • Dynamic mount point for Shared Volume Containers
  • docker cassandra with opscenter unable connected
  • Proxying Docker Containers as Subdomains
  • Reducing Disk I/O Rate of Containers
  • “Docker-compose up” does not pull images everytime , it recreates a pulled image
  • 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.

  • how to run an image of software on other node?
  • Updating Task Definitions in ECS
  • Eclipse - Docker integration
  • File copied by Docker seen as a directory
  • Version error in AWS Elastic beanstalk for Multicontainer Docker Configuration
  • How to join the default bridge network with docker-compose?
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.