2
votes

I've been working on an ansible playbook to start a private docker registry but I'm having an issue getting docker to run. The problem that I'm coming across is that the docker daemon isn't starting properly.

I'm trying to start the docker daemon on an aws ec2 instance which I've done in the past. The host os is ubuntu 14.04.

The first container I start is a Redis instance, it should start with the following play

- name: Run a Redis instance
  sudo: yes
  docker: 
    image: dockerfile/redis
    ports: 6379:6379
    name: redis
    volumes: "{{ host_redis_config_dir }}:{{ container_redis_config_dir }}"
    state: running
    command: "redis-server {{ container_redis_config_dir}}/{{ host_redis_config }}"

It fails every time with the following error

failed: [ec2-54-68-242-100.us-west-2.compute.amazonaws.com] => {"changed": false, "failed": true} msg: ConnectionError(MaxRetryError("UnixHTTPConnectionPool(host='localhost', port=None): Max retries exceeded with url: /run/docker.sock/v1.12/containers/json?all=1&limit=-1&trunc_cmd=1&size=0 (Caused by : [Errno 111] Connection refused)",),)

FATAL: all hosts have already failed -- aborting

I have tried putting

service docker start

and

shell: sudo docker -d &

Ahead of the play to force the daemon to start (tried each at a different time and on a separate ec2), neither give an error, but they don't stop the previously mentioned error.

I can ssh into the ec2 and start the daemon manually with

sudo docker -d &

and then start the Redis instance manually, but the goal is for this process to be automated with the ansible playbook in case we ever need to build additional docker registries.

Does anyone have a suggestion for how I can use ansible to insure that the daemon is starting?

1

1 Answers

0
votes

In 14.04 the service name is docker.io.

I can recreate your issue precisely by manually stopping the docker.io service and successfully restart it as part of the play with the following.

service: name=docker.io state=started