louislam / dockge

A fancy, easy-to-use and reactive self-hosted docker compose.yaml stack-oriented manager
https://dockge.kuma.pet
MIT License
13.13k stars 375 forks source link

Networks > External Network has no effect #594

Open imjustleaving opened 3 months ago

imjustleaving commented 3 months ago

⚠️ Please verify that this bug has NOT been reported before.

🛡️ Security Policy

Description

I am trying to replicate the Join Networks feature in Portainer by using the sliders in the External Network section when I deploy or edit a container.

👟 Reproduction steps

  1. create a docker network (docker network create testnet)
  2. add a container (for this use-case i used prowlarr)
  3. move the slider under External Networks to "testnet"
  4. deploy
  5. verify container is on network (docker network inspect testnet)
  6. "Containers": {}, line is empty confirming no container exist on the network testnet

👀 Expected behavior

the Containers: {} line should have the info for the containers I selected to join the testnet network, in this case, prowlarr

😓 Actual Behavior

Containers: {} line remained empty.

Dockge Version

1.4.2

💻 Operating System and Arch

Ubuntu 24.04

🌐 Browser

Firerfox 129.0

🐋 Docker Version

Docker 26

🟩 NodeJS Version

No response

📝 Relevant log output

No response

Persil090 commented 2 months ago

yup same issue here

clupss commented 1 month ago

Hi, I thought this was a bug also, but it's not. You're specifying the network in the compose file with the "External networks" slider. You still need to tell the container to use the network also. image This screenshot shows that the slider adds the network to the compose file, but you still need to add it in the container config in the compose file.

You can do that by typing it manually: image Or you can do it by editing the container settings in dockge: image (At the bottom, whole screenshot added for context).

tabula-raza commented 1 month ago

thanks @clupss - I had this same issue and your explanation helped (I somehow missed that 'edit' button for each container...)

Some of my confusion stems from the docker compose documentation for using pre-existing networks which says that if an external network is defined in the top-level network element , compose will look for it and attach containers to it if it exists (instead of creating a network).

Implied by the language and example are: 1) if no other networks are specified in the network top level element, and 2) if no networks are specified in the service top-level element, then 3) the network defined in the network top level element will be treated as the default network, and containers will be attached to it.

Screenshot 2024-09-24 at 1 06 26 PM

It might be documented somewhere else but it seems that the following rules apply: 1) unless a network is specified in the service element, the container will join a default network, and 2) the default network will always be a container specific bridge network unless the default is explicitly defined in the network top-level element.

Which leads me to the following feature request: 1) a toggle in the network block of the compose editor to designate a network that you've toggled on as the default network (which would adjust the formatting of that network element appropriately), e.g. from:

networks:
    networkname:
        external: true

to:

networks:
    default:
        name: networkname
        external: true
brianmiller commented 1 month ago

thanks @clupss - I had this same issue and your explanation helped (I somehow missed that 'edit' button for each container...)

Some of my confusion stems from the docker compose documentation for using pre-existing networks which says that if an external network is defined in the top-level network element , compose will look for it and attach containers to it if it exists (instead of creating a network).

Implied by the language and example are: 1) if no other networks are specified in the network top level element, and 2) if no networks are specified in the service top-level element, then 3) the network defined in the network top level element will be treated as the default network, and containers will be attached to it.

Screenshot 2024-09-24 at 1 06 26 PM

It might be documented somewhere else but it seems that the following rules apply: 1) unless a network is specified in the service element, the container will join a default network, and 2) the default network will always be a container specific bridge network unless the default is explicitly defined in the network top-level element.

Which leads me to the following feature request: 1) a toggle in the network block of the compose editor to designate a network that you've toggled on as the default network (which would adjust the formatting of that network element appropriately), e.g. from:

networks:
    networkname:
        external: true

to:

networks:
    default:
        name: networkname
        external: true

This worked for me. Thank you.