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..
- I didn't recognize command option's reference detail. Is parameter type string? list? fmm??
- Importance of ENTRYPOINT(docker-php-entrypoint?? what's this?)
-
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
docker_container:
name: php7-fpm
auto_remove: yes
command: [
"bash",
"-c","
'apt update && apt install zlib1g-dev && docker-php-ext-install zip && docker-php-ext-install pdo_mysql && php-fpm'"
]
image: php:7-fpm
exposed_ports:
- 9000
state: started
Answer of my struggles
1.
A command option of docker_container can receive one of shell command.
["ping","127.0.0.1","-c","5"]
"ping 127.0.0.1 -c 5"
Both styles can use too.
2.
"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.
3.
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.
thanks.