Docker Community Forums

Share and learn in the Docker community.

Network configuration (container visibility on the local network)

I study Docker. There are 2 containers (application and database). How to properly configure the network in Dokker so that users from the local network can connect to the application server?

I want to configure the network in the docker-composite configuration file. I hope this is possible?

docker-compose.yml
version: "3.5"
services:

  db:
    image: mongo:3.0
    command: mongod --smallfiles --oplogSize 128
    networks:
      - rocket_chat_network

  rocketchat:
    image: rocketchat/rocket.chat:latest
    environment:
      - PORT=3000
      - ROOT_URL=http://docker:3000
      - MONGO_URL=mongodb://db:27017/rocketchat
    links:
      - db:db
    ports:
      - 3000:3000
    networks:
      - rocket_chat_network

  networks:
    rocket_chat_network:
      name: rchat_neork
      driver: bridge

I get an error with the current file:

PS C:\rocket\chat> docker-compose up -d
ERROR: The Compose file ‘.\docker-compose.yml’ is invalid because:
Unsupported config option for services.networks: ‘rocket_chat_network’

Guided by example of docker docs.

I will be glad to any help (be it an algorithm of actions, links to training material, correction of my configuration file). Thanks in advance!

Hi :slight_smile:

You’re really close :slight_smile:

“networks” is not a part of “services”, its a thing of its own.
So if you just pad this part all to the left:

   networks:
     rocket_chat_network:
       name: rchat_neork
       driver: bridge

You should be fine :slight_smile:

And since you exposed port 3000:

ports:
      - 3000:3000

you should be able to access it on port 3000 on the servers/workstations hostname/ip