How to start a docker container with healthstatus using Ansible

0 votes

Hi Guys,

I want to launch one docker container using the Ansible playbook. I also want to check the healthstatus of this container. How can I do that?

Sep 20, 2020 in Ansible by akhtar
• 38,170 points
419 views

1 answer to this question.

0 votes

Hi@akhtar,

You can use the docker_container module in your Ansible playbook. This module has an argument to check the health of a container. You can see the below playbook.

- name: Start container with healthstatus
  docker_container:
    name: nginx-proxy
    image: nginx:1.13
    state: started
    healthcheck:
      # Check if nginx server is healthy by curl'ing the server.
      # If this fails or timeouts, the healthcheck fails.
      test: ["CMD", "curl", "--fail", "http://nginx.host.com"]
      interval: 1m30s
      timeout: 10s
      retries: 3
      start_period: 30s
answered Sep 20, 2020 by MD
• 95,160 points

Related Questions In Ansible

0 votes
1 answer

How to start httpd service in a remote system using Ansible?

Hi@akhtar, Ansible has a module named service. This ...READ MORE

answered Jul 30, 2020 in Ansible by MD
• 95,160 points
493 views
0 votes
1 answer

How to pull a docker image using Ansible playbook?

Did you try using this? https://docs.ansible.com/ansible/latest/colle ...READ MORE

answered Nov 5, 2020 in Ansible by undermink
2,241 views
0 votes
1 answer

How to launch MySQL docker container using Ansible playbook?

Hi@akhtar, You can use docker_container module in your ...READ MORE

answered Sep 20, 2020 in Ansible by MD
• 95,160 points
632 views
0 votes
1 answer

How to use Ansible git module pull a branch with local changes?

You cannot achieve it using the git ...READ MORE

answered Jul 9, 2018 in Ansible by Atul
• 10,240 points
4,002 views
+2 votes
1 answer
+2 votes
1 answer

Deploy Docker Containers from Docker Cloud

To solve this problem, I followed advice ...READ MORE

answered Sep 3, 2018 in AWS by Priyaj
• 58,120 points
1,143 views
0 votes
1 answer

How to create a docker container using Ansible playbook?

Hi@akhtar, You can use the docker_container module in ...READ MORE

answered Aug 7, 2020 in Ansible by MD
• 95,160 points
2,065 views
0 votes
1 answer

How to create a docker container using Ansible?

Hi@akhtar, You can use the docker_container module in ...READ MORE

answered Sep 20, 2020 in Ansible by MD
• 95,160 points
186 views