How to use docker-php-ext-install command on the docker_container of ansible modules.

I faced any problems that is couldn't use command option of a docker_container module.

I need customize php-fpm container, so I used docker-php-ext-install command in docker_container's command option. But I had any struggle points.

My struggles..

  1. I didn't recognize command option's reference detail. Is parameter type string? list?  fmm??
  2. Importance of ENTRYPOINT(docker-php-entrypoint?? what's this?)
  3. In using command option,Docker container shutting down immediately.

    • PHP-fpm container is uses exposed port. Why shutting down????

How to

Let me get straight the point, this playbook is a my solution.

- name: Deploy PHP7 on docker container
      name: php7-fpm
      auto_remove: yes
      command: [
        'apt update && apt install zlib1g-dev && docker-php-ext-install zip && docker-php-ext-install pdo_mysql && php-fpm'"
      image: php:7-fpm
        - 9000
      state: started

Answer of my struggles


A command option of docker_container can receive one of shell command.


"ping -c 5"

Both styles can use too.


"docker-php-entrypoint" distinguish argument's -

If entrypoint option and command option that both have a some parameter, Executing that the command option is option of entrypoint's.


PHP7-fpm docker container runs php-fpm shell command on the command that is equivalent of dockerfile's CMD directive. However, my wrong playbook didn't have php-fpm command at last. Therefore all commands successfully done, and container shutting down.

command: [
        "bash","-c","'apt update && apt install zlib1g-dev && docker-php-ext-install zip && docker-php-ext-install pdo_mysql"

So, bash commands option helped my solution.

"/bin/bash -c '{any commands of combined from &&}'"

Please your advices, comments.