# Access IPFS running on host machine from docker container

**URL:** <https://discuss.ipfs.tech/t/access-ipfs-running-on-host-machine-from-docker-container/1986>\
**Category:** Help\
**Created:** [February 1, 2018, 11:48pm UTC](https://discuss.ipfs.tech/t/access-ipfs-running-on-host-machine-from-docker-container/1986 "2018-02-01T23:48:30Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![tk89](https://avatars.discourse-cdn.com/v4/letter/t/8e7dd6/32.png) [@tk89](https://discuss.ipfs.tech/u/tk89)\
**Post date:** [February 1, 2018, 11:48pm UTC](https://discuss.ipfs.tech/t/access-ipfs-running-on-host-machine-from-docker-container/1986/1 "2018-02-01T23:48:30Z")

</div>

Does anyone have experience how to access IPFS from a docker container using python api (ipfsapi) ? It seems that I cannot connect to localhost, where IPFS is running from the docker container.  
This is the command to connect:  
api = ipfsapi.connect(‘127.0.0.1’, 5001)

**EDIT** : I figured out that from mac I should use  
api = ipfsapi.connect(‘docker.for.mac.host.internal’,5001)  
and it works fine.  
What exactly is “docker.for.mac.host.internal” ?  
How can I connect from linux machines?

---

<div class="post-metadata">

**Author:** ![josselinchevalay](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/josselinchevalay/32/3078_2.png) [@josselinchevalay](https://discuss.ipfs.tech/u/josselinchevalay)\
**Post date:** [February 2, 2018, 7:34am UTC](https://discuss.ipfs.tech/t/access-ipfs-running-on-host-machine-from-docker-container/1986/2 "2018-02-02T07:34:18Z")

</div>

quick question : could you share your docker ps result please ?

---

<div class="post-metadata">

**Author:** ![tk89](https://avatars.discourse-cdn.com/v4/letter/t/8e7dd6/32.png) [@tk89](https://discuss.ipfs.tech/u/tk89)\
**Post date:** [February 2, 2018, 8:39am UTC](https://discuss.ipfs.tech/t/access-ipfs-running-on-host-machine-from-docker-container/1986/3 "2018-02-02T08:39:55Z")

</div>

Here it is:

> CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES  
> a9b384196a2c ubuntu “/bin/bash” 9 hours ago Up 8 hours testipfs

and I run the container like this:

> docker run -it --name testipfs ubuntu

I also tried with docker run -it -p 5001:5001 --name testubuntu ubuntu

---

<div class="post-metadata">

**Author:** ![josselinchevalay](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/josselinchevalay/32/3078_2.png) [@josselinchevalay](https://discuss.ipfs.tech/u/josselinchevalay)\
**Post date:** [February 2, 2018, 8:43am UTC](https://discuss.ipfs.tech/t/access-ipfs-running-on-host-machine-from-docker-container/1986/4 "2018-02-02T08:43:44Z")

</div>

maybe you can try with image [https://hub.docker.com/r/ipfs/go-ipfs/](https://hub.docker.com/r/ipfs/go-ipfs/) there are Docker file [https://github.com/ipfs/go-ipfs/blob/master/Dockerfile](https://github.com/ipfs/go-ipfs/blob/master/Dockerfile) please publish 5001 4001 4001/udp 8080 8081

reagards

---

<div class="post-metadata">

**Author:** ![tk89](https://avatars.discourse-cdn.com/v4/letter/t/8e7dd6/32.png) [@tk89](https://discuss.ipfs.tech/u/tk89)\
**Post date:** [February 2, 2018, 9:38pm UTC](https://discuss.ipfs.tech/t/access-ipfs-running-on-host-machine-from-docker-container/1986/5 "2018-02-02T21:38:05Z")

</div>

I would like to my own image…

---

<div class="post-metadata">

**Author:** ![jeffreycwitt](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/jeffreycwitt/32/3668_2.png) [@jeffreycwitt](https://discuss.ipfs.tech/u/jeffreycwitt)\
**Post date:** [February 3, 2018, 1:09pm UTC](https://discuss.ipfs.tech/t/access-ipfs-running-on-host-machine-from-docker-container/1986/6 "2018-02-03T13:09:04Z")

</div>

don’t you just need to connect from ‘0.0.0.0’, 5001 (instead of 127.0.0.1) when running within a container. I think that should work on both Mac and Linux

Here’s my Docker file [https://github.com/jeffreycwitt/dll-review-registry/blob/master/Dockerfile](https://github.com/jeffreycwitt/dll-review-registry/blob/master/Dockerfile) and and ipfs config file:  
[https://github.com/jeffreycwitt/dll-review-registry/blob/master/ipfs-config.json](https://github.com/jeffreycwitt/dll-review-registry/blob/master/ipfs-config.json)

---

<div class="post-metadata">

**Author:** ![jeffreycwitt](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/jeffreycwitt/32/3668_2.png) [@jeffreycwitt](https://discuss.ipfs.tech/u/jeffreycwitt)\
**Post date:** [February 3, 2018, 1:14pm UTC](https://discuss.ipfs.tech/t/access-ipfs-running-on-host-machine-from-docker-container/1986/7 "2018-02-03T13:14:46Z")

</div>

I could be wrong, but isn’t it best not to expose 5001. Usually 5001 is only needed internally within the Docker container to run CLI commands.

My understanding is that you would only want to expose it if you wanted to be able to remotely control the CLI

See [Cannot transfer between two firewalled machines](https://discuss.ipfs.tech/t/cannot-transfer-between-two-firewalled-machines/505/7)

---

<div class="post-metadata">

**Author:** ![tk89](https://avatars.discourse-cdn.com/v4/letter/t/8e7dd6/32.png) [@tk89](https://discuss.ipfs.tech/u/tk89)\
**Post date:** [February 3, 2018, 2:08pm UTC](https://discuss.ipfs.tech/t/access-ipfs-running-on-host-machine-from-docker-container/1986/8 "2018-02-03T14:08:55Z")

</div>

So 5001 is for controlling the ipfs daemon you mean?

@jeffreycwitt I will try

> ‘0.0.0.0’, 5001

---

<div class="post-metadata">

**Author:** ![jeffreycwitt](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/jeffreycwitt/32/3668_2.png) [@jeffreycwitt](https://discuss.ipfs.tech/u/jeffreycwitt)\
**Post date:** [February 3, 2018, 2:11pm UTC](https://discuss.ipfs.tech/t/access-ipfs-running-on-host-machine-from-docker-container/1986/9 "2018-02-03T14:11:45Z")

</div>

that’s my understanding.

But since 5001 is only needed inside the container 127.0.0.1 should work

But if you want to access 4001 and 8080 outside the container you should set the config to 0.0.0.0
