Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

434
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda