Docker Community Forums

Share and learn in the Docker community.

Why can't I run multiple containers that use TCP?

I’m trying to run a second Meteor app in a Docker’s container. The first (who is running as I want) is accessible with localhost:3000 and I want to run a second one in a other port like localhost:3003. When I try to access the second I got this

This website is not accessible. Localhost don’t allow the connexion. Do a research about localhost 3003 on Google.

And If I look into Docker I can see that my containers are running:

but I noticed a difference between the port, the one who is accessible is 0.0.0.0:3000->3000/tcp and the one who isn’t accessible is 3000/tcp, 0.0.0.0:3003->3003/tcp so I think there is something wrong here.

And in my docker-compose.yml I did :

app:
  image: jeromevi/controlcontainersapp
  ports:
    - "3003:3003"
  environment:
    - ROOT_URL=http://localhost:3003
    - MONGO_URL=mongodb://mongo:27017/meteor
mongo:
  image: mongo:latest

Thank you for the help

The solution is to change the docker-compose like this:

version: '2'
services:
  app:
    image: jeromevi/controlcontainersapp
    ports:
      - "3003:3000"
    environment:
      - ROOT_URL=http://localhost:3000
      - MONGO_URL=mongodb://mongo:27017/meteor
    networks:
      - <your network name>
  mongo:
    image: mongo:latest
    networks:
      - <your network name>
networks:
  <your network name>:
    external: true

And to create a network.