Docker Community Forums

Share and learn in the Docker community.

I need help , I want to use alias network docker compose with `bridge`

When using composefile version 3.8 with the default bridge network this error occurs:

$ docker-compose up -d
Creating mongopos ... error

ERROR: for mongopos  network-scoped alias is supported only for containers in user defined networks

ERROR: for mongopos  network-scoped alias is supported only for containers in user defined networks
ERROR: Encountered errors while bringing up the project.

My docker compose file :

version: '3.8'

services:
  mongopos:
    container_name: mongodb
    image: mongo:4.0.10
    restart: always
    networks:
      default:
        aliases:
          - mongodb
    ports:
      - 4001:27017

networks:
  default:
    external:
      name: bridge

docker-compose version 1.25.5