nickjj / ansible-docker

Install / Configure Docker and Docker Compose using Ansible.
MIT License
750 stars 224 forks source link

Cannot pre-configure new home for docker #80

Closed pcolmer closed 4 years ago

pcolmer commented 4 years ago

By default, docker will use /var/lib/docker for its files. However, we tend to use /srv/docker as our /srv/ partitions are where we store the application files and data, so it tends to be much bigger than the root partition.

Telling docker to use a different directory is achieved by setting the graph value in /etc/docker/daemon.json. If the file exists before docker is installed then it uses it straightaway and nothing gets created in /var/lib.

However, when I try to set graph via the playbook configuration, everything installs but the service then fails to start. I think this is happening because docker is installed then /etc/docker/daemon.json is created, which means that docker has already set up /var/lib/docker.

Would it be possible to move the initialization of /etc/docker/daemon.json to before you install docker so that it picks up the values before it first runs?

nickjj commented 4 years ago

Hi,

Would you be open to submitting a PR that does this?

pcolmer commented 4 years ago

@nickjj I'll certainly give it a try.

The "easy" option of just setting up /etc/docker/daemon.json before Docker is installed is a fairly trivial change and I should be able to get that done today.

There is a bigger picture, though, and that is supporting changes to the graph value before and after Docker is installed. That is a much more complex bit of logic and therefore more complex playbook to put together. I will have a go at doing that, though, if for no other reason than it will help improve my Ansible skills :) It won't be today though ... :)

pcolmer commented 4 years ago

https://github.com/nickjj/ansible-docker/pull/81

nickjj commented 4 years ago

Fixed in master.