How can i force remove a docker container using 'docker_container' module of Ansible? -
i having problems removing containers docker host after introducing cadvisor - https://github.com/google/cadvisor/issues/771
i have large number of ansible (2.2.1.0) scripts use install service containers on these docker host , internally using docker_container module. many times these scripts want remove container, because of problem stated above, failing.
i can force kill docker container on these docker hosts easily:
docker rm container_name -fv
so expect force_kill option provided in docker_container module (docker_container module docs) should able same:
- name: delete docker containers docker_container: name: "container_name" force_kill: true keep_volumes: false state: absent
but script fail always. not know purpose of option if not able force kill it. of scripts failing after enabling force_kill , need know how make sure option works intended ?
update: understand force_kill option sending docker kill signal. have updated question better reflect want achieve.
i think force_kill
sends kill signal docker kill so
the main process inside container sent sigkill, or signal specified option --signal.
i check cmd and/or entrypoint in dockerfile of image (if used it) because
entrypoint , cmd in shell form run subcommand of /bin/sh -c, not pass signals. means executable not container’s pid 1 , not receive unix signals.
cmd ["/init.sh"] # exec form cmd /init.sh # shell form
not sure reason of problem, may cmd in shell form doesn't forward signal command.
always use exec form if want docker forward signals (sub-)process. not important sending custom signals docker container, it’s important stop (i.e. docker stop) container.
Comments
Post a Comment