Ionic serve --lab & docker: connection reset by peer

Hi there!

I installed ionic in a docker image. When running the container, I open the ports 8200 and 8100:

Then, in a browser, I can access http://localhost:8100 and see the ionic app. However, I can’t access the lab when I go to http://localhost:8200 the browser (firefox) says: “connection reset by peer”. If I try http://localhost:8300, the browser says “unable to connect”.

I’m guessing that requests on port 8200 arrive somewhere in the container but are refused in there.

When I run the following command, I still have nothing. (no log when accessing through port 8200, altough I have logs when accessing trhough 8100)

ionic serve --lab -c --verbose --host 0.0.0.0

Is there any way to check what is going on? I have no idea where to start looking. There is nothing on the /var/log of the container :-/

Thanks for your advice :slight_smile: ,
Eldorico

EDIT: thats the result of netstat -tupln. Is there a hint I could exploit?

root@a71384711be9:/home/app# netstat -tupln | grep -E "8100|8200|Proto"
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:8100            0.0.0.0:*               LISTEN      205/node            
tcp        0      0 127.0.0.1:8200          0.0.0.0:*               LISTEN      237/ionic-lab       
root@a71384711be9:/home/app# 
1 Like

I found a workaround ^^

Since I think (but not sure) that ionic-lab only wants requests from within the same machine, I installed haproxy in the docker image to redirect requests from 0.0.0.0:1234 (from any) to 127.0.0.1:8200 (local == same machine). I can now access to the lab page using my browser at localhost:1234, because haproxy receives the requests from outside, and redirects to 127.0.0.1:8200. Since haproxy is inside the docker container, ionic-lab accepts requests from haproxy, which redirects to outside of the container.

I’m still wondering if I can access to the ionic lab without any proxy :face_with_monocle:

If somebody knows the answer, I will be happy to know it :grimacing:

Here is the docker parts regarding the workaround I used:
Dockerfile:

RUN apt install -y haproxy
ADD haproxy.cfg /etc/haproxy/haproxy.cfg

haproxy.cfg: the default /etc/haproxy/haproxy.cfg file installed with haproxy, with theses lines appened

frontend ionic_fe
	bind *:1234
	default_backend ionic_be

backend ionic_be
	server localhost 127.0.0.1:8200

docker-compose.yaml

[...]
        entrypoint: /bin/bash -c "service haproxy start && ionic serve --lab -c --host 0.0.0.0"
[...]
        ports:
            - "8200:8200"
            - "8100:8100"
            - "1234:1234"
1 Like

try command ionic cli, example: ionic serve --port 8100 --address=127.0.0.1

Fore it to be accessible on your host from dokcer, you need to run it with the address 0.0.0.0

ionic serve --port 8100 --address=0.0.0.0