So I have a multicontainer app in which one of the containers is a node socket-server to be used from the client side of a web server in another container, using socket_io_2_0_3 library.
Importing the lib
connect to it:
var socket = io('http://localhost:3334');
in this example case, the socket-server is running in local on port 3334.
In my real scenario I’m running the socket server on a container, and the webserver in another, with a compose file looking something like:
version: '2' services: nginx: build: ./nginx depends_on: - web ports: - "80:80" ss1: build: ./socket-server command: bash /tmp/start.sh ports: - "3334:3334" web: build: ./first-pitch command: bash /tmp/start.sh depends_on: - ss1 ports: - "3000:3000"
one might think it should be called something like:
var socket = io('http://ss1:3334');
But, I get an error when reaching through the public URL.
How am I supposed to link to a container from the clients JS side?