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.

  • Syslog from nginx Docker container to logstash
  • Error when installing docker-compose using ansible-playbook
  • pip install pymssql from inside docker container
  • Bamboo: More than one agent per EC2 elastic instance?
  • Meteor run server getting error: “Could not locate the bindings file. […]bcrypt[…]”
  • When would I use `--interactive` without `--tty` in a Docker container?
  • 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 restore a postgres database with fig?
  • How to parameterize Dockerfile?
  • Reset IP counter used by docker
  • SSH server does not accept connections
  • How can my docker harddrive be bigger than the hosts?
  • Running Jenkins tests in Docker containers build from dockerfile in codebase
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.