1

I have the following configuration in Raspberry Pi for iptables

            pi@raspberrypi:~ $ sudo iptables --list
            Chain INPUT (policy ACCEPT)
            target     prot opt source               destination
            ACCEPT     all  --  anywhere             anywhere
            REJECT     all  --  anywhere             loopback/8           reject-with icmp-port-unreachable
            ACCEPT     all  --  anywhere             anywhere             state RELATED,ESTABLISHED
            ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:http
            ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:https
            ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:http-alt
            ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:8181
            ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:8182
            ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:ssh
            ACCEPT     icmp --  anywhere             anywhere
            LOG        all  --  anywhere             anywhere             limit: avg 5/min burst 5 LOG level debug prefix "iptables denied: "
            DROP       all  --  anywhere             anywhere

            Chain FORWARD (policy DROP)
            target     prot opt source               destination
            DOCKER-USER  all  --  anywhere             anywhere
            DOCKER-ISOLATION  all  --  anywhere             anywhere
            ACCEPT     all  --  anywhere             anywhere             ctstate RELATED,ESTABLISHED
            DOCKER     all  --  anywhere             anywhere
            ACCEPT     all  --  anywhere             anywhere
            ACCEPT     all  --  anywhere             anywhere
            DROP       all  --  anywhere             anywhere

            Chain OUTPUT (policy ACCEPT)
            target     prot opt source               destination
            ACCEPT     all  --  anywhere             anywhere

            Chain DOCKER (1 references)
            target     prot opt source               destination
            ACCEPT     tcp  --  anywhere             172.17.0.2           tcp dpt:8181

            Chain DOCKER-ISOLATION (1 references)
            target     prot opt source               destination
            RETURN     all  --  anywhere             anywhere

            Chain DOCKER-USER (1 references)
            target     prot opt source               destination
            RETURN     all  --  anywhere             anywhere

and I have exposed port 8181 in Docker file. This device has a static IP of 192.168.100.20 and I can ping in to it from my host machine.

This is the docker file configuration

            FROM myapp

            COPY . /app
            RUN pip install -e /app
            WORKDIR /app/node

            EXPOSE 8181

            ENTRYPOINT [ "myapp", "run" ]

I am running as docker run -p 8181:8181 <image_id>

But when I tried to access it by its IP, it says address not found and when I do a port scan, I'm getting the following result

            Discovered closed port 8181/tcp on 192.168.100.20
            8181/tcp  closed   intermapper          conn-refused

What prevents accessing it from outside the Raspberry Pi device ?

  • Just to make sure it isn't something with docker interface configuration, explicitly list your external interface as in -p 192.168.100.20:8181:8181 or, alternatively, -p 0.0.0.0:8181:8181 – crasic Nov 28 '17 at 22:45
  • @crasic I tried it and didnt work – co2f2e Nov 28 '17 at 23:51
  • On the host machine, can you connect directly to the container at 172.17.0.2:8181 – crasic Nov 29 '17 at 0:16
  • @crasic seems I cannot connect did a curl for 172.17.0.1:8181 – co2f2e Nov 29 '17 at 1:11
  • 1
    Are you sure that is the container IP? docker inspect <container_id>. In any case, if that is the container IP then the firewall/networking is not the problem, but your image does not have anything bound to that port, or, you have configured the image to block that port. Even though it is exposed in Dockerfile, there is "no one home" so to speak. – crasic Nov 29 '17 at 1:14
1

What does 'myapp' do ?

Are you sure it does listen on port 8181 of the container's external interface (or on all interfaces) ?

Are you sure 'myapp' starts correctly ?

Does

$ docker logs <container id>

give you any error or debug message ?

If your images contains netstat, the output of

$ docker exec <container id> netstat -lnp

would show if anything in the container listens on the public port 8181.

To debug such situations I'd recommend to start your image in interactive mode:

$ docker run -it --rm -p 8181:8181 <image_id> /bin/bash

and then start your app manually inside the container with

$ myapp run

ideally adding some flags to add more verbosity to your app if your app supports it.

It doesn't seem to be a raspberry issue but a configuration of your image.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.