I am currently working on a project where I remake an existing project to be used in docker containers.
I have 3 different containers:
If I understood your deploy architecture, the
application need access
nodeserver via socket.io on port 3001, so you add a link with nodeserver to application, it's correct.
nodeserver serve a webpage that also connects to socket.io on port 3001, so the browser cannot connects nodeserver on port 3001.
So you just need to change
nodeserver as below:
nodeserver: ports: - "3000:3000" - "3001:3001" links: -database ...
Link to containers in another service. Either specify both the service name and a link alias (SERVICE:ALIAS), or just the service name.
Containers for the linked service will be reachable at a hostname identical to the alias, or the service name if no alias was specified.
Expose ports. Either specify both ports (HOST:CONTAINER), or just the container port (a random host port will be chosen).
Expose ports without publishing them to the host machine - they’ll only be accessible to linked services. Only the internal port can be specified.
See more details: https://docs.docker.com/compose/compose-file