Exposing port 4001 via docker

Continuing the discussion from Cannot transfer between two firewalled machines:

The above thread was very helpful in understanding how the different ports works.

In light of this I’m now trying to expose port 4001 via my docker container. My hope would be that when the container is running, and port 4001 is exposed, my container will be connected the ipfs network and that the files that it has pinned within the container will be accessible via other gateways such as http://gateway.ipfs.io/

Everything seems to be working great until I requested the pinned file from http://gateway.ipfs.io/ipfs/QmbYGdVTJdszMhyqTrAPWFk1ubQ66XsiLHpiGQeRb5qs23 where in the request simply hangs.

IPFS is getting installed in my container via my docker file like so: (below is a snippet taken from the complete Dockerfile)

`ENV IPFS_DIST_URL=https://dist.ipfs.io/go-ipfs/v0.4.10/go-ipfs_v0.4.10_linux-amd64.tar.gz

wget -qO- ${IPFS_DIST_URL} | tar xz -C ~/tmp/ ;
mv ~/tmp/go-ipfs/ipfs /usr/local/bin/ ; rm -rf ~/tmp/*

RUN ipfs --version
RUN mkdir -p /data/ipfs
RUN ipfs init


Then I’m starting docker with docker-compose, like so

version: '2' services: web: build: . image: dll-review-registry volumes: - .:/dll-review-registry ports: - "4567:4567" - "4001:4001" - "8080:8080" env_file: - "github-variables.env" environment: - RACK_ENV=docker links: - mongodb depends_on: - mongodb

I then initiate the daemon in the container like so:

docker exec dllreviewregistry_web_1 ipfs daemon

and the console responds with:

Initializing daemon... Swarm listening on /ip4/ Swarm listening on /ip4/ API server listening on /ip4/ Gateway (readonly) server listening on /ip4/

Everything seems to be running great. Listening docker ports reads as follows:

docker port dllreviewregistry_web_1 4001/tcp -> 4567/tcp -> 8080/tcp ->

Likewise I can also run

docker exec dllreviewregistry_web_1 ipfs cat QmRmSH4hAn76qGprHUvd9jxv3axoyb9t8cad2A9TogfHgf

and get back the contests of the requested document.

However, if I navigate to http://localhost:8080/ipfs/QmRmSH4hAn76qGprHUvd9jxv3axoyb9t8cad2A9TogfHgf in my browser I get NO response.

Likewise, https://gateway.ipfs.io/QmRmSH4hAn76qGprHUvd9jxv3axoyb9t8cad2A9TogfHgf gives me a page not found.

But if I go inside the container, and run
curl http://localhost:8080/ipfs/QmRmSH4hAn76qGprHUvd9jxv3axoyb9t8cad2A9TogfHgf
then I am able to access the content.

My guess is that the problem lies in discrepancy between the demon listening at and the fact that Docker is mapped to

Any ideas how I can get the daemon to expose ports at instead of or am I overlooking some other big problem??

Thanks for your help.

An update to my own question.

I started to realize I can make this change from to in the config file.

I changed this for port 8080 and I’m now able to dereference the hash in my browser.

However, I’m still NOT able to access the file at any of the other gateways, which makes me think I’m still missing a connection at :4001.

This is odd because in the config file address is already listed at

“Swarm”: [

But when the daemon runs it says it is listening at
Swarm listening on /ip4/

Is there something else I need to change, so that my docker container can fully expose port 4001, such that pinned files are accessible at other gateways on the network??

hi jeff

i’m not sure but maybe you need to open and expose also this port 5001 see that : https://github.com/ipfs/go-ipfs/blob/959ee92edd65c1d39d72e4822f59be61a48430de/Dockerfile#L58