MIDE11
MIDE11

Reputation: 3530

Ansible - Docker / container doesn't start automatically after reboot

I have the following ansible code:

- name: Run mycontainer
  docker_container:
    name: "{{ my_container }}"
    image: "my_container:{{ my_container_version }}"
    pull: true
    state: started
    restart_policy: always

When I reboot the machine and the machine is back to normal, the container status is: Exited (1) 6 minutes ago. When I restarted it manually by docker restart mycontainer, its up again.

As I understand, restart_policy: always should handle this case. What am I doing wrong?

Upvotes: 2

Views: 1959

Answers (1)

MIDE11
MIDE11

Reputation: 3530

The problem was that Ansible didn't change the restart_policy param to always, checked by docker inspect -f "{{ .HostConfig.RestartPolicy }}" mycontainer.

just after removing the container, and deploy it again - it was fixed.

Upvotes: 2

Related Questions