since Ansible 2.0 it is possible to deploy directly to a docker container via connection=docker. Now I want to create a Role which is starting a Docker container and deploying some stuff to it. Here is an arbitrary example of my current solution:
This approach works quite fine since I deploy the role on my localhost. Because the deletage_to directive is delegating from the ansible machine (my localhost) it will find the docker container started. If I deploy the Role on a remote host, the container will be started on the remote host, but the delegate_to directive will looking for the container on the local host. Currently there is no documentation of the docker connection. Does anybody know how I redirect the docker connection to the remote host I started the container in?
the docker connection plugin will only connect to hosts on the ansible
control machine, it is using the local execution tools to access the
docker instance w/o using ssh.
Thank you for quick reply. Is it possible to pass the -H / --host parameter to the local docker binary, such that you can specify the socket to talk to the (remote) Docker daemon (e.g. tcp://myhost:port/path)?
The current docker connection plugin does not seem to support that
(yet). I suggest opening a github feature request to allow for usage
with the docker daemon.
Is there a possibility to define the command docker is called with? This would solve my problem, since I have created an alias calling the remote Docker daemon. Within the connection/docker.py there is following code: