# How to connect to cdh docker image using Ansible

**URL:** <https://forum.ansible.com/t/how-to-connect-to-cdh-docker-image-using-ansible/32974>\
**Category:** Ansible Developer\
**Created:** [May 19, 2020, 4:15pm UTC](https://forum.ansible.com/t/how-to-connect-to-cdh-docker-image-using-ansible/32974 "2020-05-19T16:15:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Galena\_Teneva](https://avatars.discourse-cdn.com/v4/letter/g/c67d28/32.png) [@Galena\_Teneva](https://forum.ansible.com/u/Galena_Teneva)\
**Post date:** [May 19, 2020, 4:15pm UTC](https://forum.ansible.com/t/how-to-connect-to-cdh-docker-image-using-ansible/32974/1 "2020-05-19T16:15:40Z")

</div>

I want to use Hadoop from CDH docker image. CDH image is already installed on my machine and I can run it.

> ```auto
> docker ps -a
> 
> CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
> 07a55a9d4cb9 4239cd2958c6 "/usr/bin/docker-quickstart" 18 minutes ago Up 18 minutes 0.0.0.0:32774->7180/tcp, 0.0.0.0:32773->8888/tcp container
> 
> docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' container
> 
> 172.17.0.2
> 
> ```

Local, I am writing an ansible playbook and I need to set Hadoop conf dir in CDH which is: “/etc/hadoop/conf”. How can I set the running docker image in my ansible playbook?

I tried:

> ```auto
> - name: run cloudera
> docker_container:
> name: "container"
> image: quickstart/cloudera
> command: /usr/bin/docker-quickstart"
> state: started
> ports:
> - 8888:8888
> - 7180:7180
> 
> ```

But this command runs another docker image and I would like to connect to the running one.

---

<div class="post-metadata">

**Author:** ![rhysmeister](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/rhysmeister/32/10599_2.png) [@rhysmeister](https://forum.ansible.com/u/rhysmeister)\
**Post date:** [June 2, 2020, 5:13pm UTC](https://forum.ansible.com/t/how-to-connect-to-cdh-docker-image-using-ansible/32974/2 "2020-06-02T17:13:33Z")

</div>

Probably the easiest thing to do is forward a port to ssh in your container when you launch it and then connect to that in Ansible like a standard host. That should be quite easy to do.

A quick google also shows this…

[https://docs.ansible.com/ansible/latest/plugins/connection/docker.html](https://docs.ansible.com/ansible/latest/plugins/connection/docker.html)

Not used it but again it looks simple enough.

R
