Noob Docker Network Confusion

Hello All,

I have a question. I am trying to setup a docker compose to use two separate networks.

Specifically Authentik.

This is the first container I’ve tried this on but could be wrong.

Essentially what I want to do is have the following:


postgressql:
    networks:
      - backend
redis:
    networks:
      - backend
server:
    networks:
      - backend
      - vlan16
worker:
    networks:
      - backend


networks:
  backend:
    external: true
  vlan16:
    external: true



Ive also tried this way

postgressql:
    networks:
      backend:   
redis:
    networks:
      backend:   
server:
    networks:
      vlan16:
        ipv4_address: 10.0.16.120
      backend:    
worker:
    networks:
      backend:   



networks:
  backend:
    name: 'backend'
    driver: bridge
  vlan16:
    name: 'vlan16'
    driver: 'macvlan'

I cant get either them to work the way I want them. If remove the network portion and let docker create their own, I can join the vlan and access it but if I build it into the compose I cant access the container.

Confused as to what I’m doing wrong.

Its probably something stupid but I figured I would ask

What does that mean? What do you want to achieve?

In general containers are about isolation. Unless they use network mode host, you need to publish ports to connect to them from outside.

Essentially - I wanted to put it on my vlan that I control on the backend.

With that being said unless I let it create its own network I cant directly access the container.

meaning I do not add networking blocks to the compose file I can reach it at 10.0.10.10:9443.

If i create the compose file and set a network block to use my vlan below as an example I can not connect to the container via 10.0.16.120:9443, but I can ping it.

If that makes sense.

    networks:
      macvlan:
        ipv4_address: 10.0.16.120

networks:
  macvlan:
    name: 'vlan16'
    external: 'true'    

Is this really the port the process inside the container binds? The macvlan ip directly binds the container port.