Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

432
Vistas
How can i force remove a docker container using 'docker_container' module of Ansible?

I am having problems removing containers from my docker host after introducing cadvisor - https://github.com/google/cadvisor/issues/771

I have a large number of Ansible (2.2.1.0) scripts that i use to install my service containers on these docker host and internally they are using the docker_container module. Many times these scripts would want to remove a container, but because of the problem stated above, they are failing.

I can force kill docker container on these docker hosts easily:

docker rm container_name -fv

So i would expect that the force_kill option provided in the docker_container module (docker_container module docs) should be able to do the same:

- name: Delete  docker containers
  docker_container:
    name: "container_name"
    force_kill: true
    keep_volumes: false
    state: absent

But the script fail always. I do not know what is the purpose of this option if it is not able to force kill it. All of my scripts are failing even after enabling force_kill and i need to know how to make sure this option works as intended ?

Update: I now understand the force_kill option is sending the docker kill signal. I have updated the question to better reflect what i really want to achieve.

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

I think force_kill sends a kill signal as docker kill so

The main process inside the container will be sent SIGKILL, or any signal specified with option --signal.

I would check CMD and/or ENTRYPOINT in the Dockerfile of the image (if you used it) because

ENTRYPOINT and CMD in the shell form run as a subcommand of /bin/sh -c, which does not pass signals. This means that the executable is not the container’s PID 1 and does not receive Unix signals.

CMD ["/init.sh"] # exec form
CMD /init.sh     # shell form

Not sure this is the reason of your problem, but may be that a CMD in shell form doesn't forward the signal to your command.

As for Dominique Burton's blog

Always use the exec form if you want Docker to forward signals to your (sub-)process. This is not only important for sending custom signals to a Docker container, it’s also important to properly stop (i.e. docker stop) a container.

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda