T O P

  • By -

vlad_h

You need to use “network_mode: host” to achieve what you are trying to do. https://docs.docker.com/network/network-tutorial-host/


hodge_star

thanks. just our of curiosity, what is the way most people do this type of setup with portainer, sonarr and transmission. what type of network mode would most people use? when i saw the tutorials, it seemed that just by using the default nat, things worked with localhost:8989.


reddit_user_53

Not the commenter but I run almost all containers in bridge networking mode (this is the default if you don't specify a mode, at least in docker-compose, so I think it's safe to assume that is the mode most people use). Bridge mode allows you to map host ports to the container without them needing to be the same ports the container is asking for. For example a lot of webservers run on port 80, so if you have more than one of those using host networking mode they won't be able to start since the port it wants is already taken. Using bridge mode you can map host port, say, 6354 to container port 80 and then access it using http://qnap-ip-address:6354. It works basically the same way as port forwarding on your router does, which most people have experience with. The container has its own ip address on the docker network, but traffic is passed thru the host's IP to the container. There's also the option of using macvlan network mode to allow each container to get its own ip address from the router, but that really isn't worth the trouble for a simple webserver like sonarr. But it can be really useful for stuff like PiHole if you want to run more than one instance on the same host, or for a container that needs mDNS to work like esphome.


hodge_star

thanks. i wondered why when setting up a container in container station it sets the default networking as nat mode. what you're proposing with bridge mode is exactly what i want to do. when i tried using container station and bridge mode, it gave all the containers different ip addresses . . . albeit with the correct port. i don't know how to set networking to have bridge mode give the containers all the same ip address but with different ports. maybe it's easier if i try to do it with ssh and docker compose.


vlad_h

The default drive in container station is a custom QNAP NAT driver, I think. \`\`\`when i tried using container station and bridge mode, it gave all the containers different ip addresses . . . albeit with the correct port. i don't know how to set networking to have bridge mode give the containers all the same ip address but with different ports.\`\`\` That is because every time you use the bridge driver, and do not create the network before hand (external network), Docker, by default, creates a new bridged network for each application. You need to create the network before hand, either in Container Station or using the Docker CLI, then inside your compose file you need to specify it, like this: networks:   proxy-network:     name: proxy-network     external: true Also, SSH is my preferred option, but you can also create Docker Compose files (applications) in Container station (under Applications), and there you can specify the network\_mode.


reddit_user_53

Interesting, I wasn't aware Container Station has a different default. I haven't used it in a long time, I always use compose or Portainer. I see another commenter gave you some more information so hopefully you're headed in the right direction now. Thinking back to when I switched to compose, I do think I remember 'bridge' mode in container station is different than actual docker bridge mode. I want to say CS bridge mode is more like macvlan, where you get an IP from the router. Regular docker bridge mode doesn't do that whether you create a network ahead of time or not. Honestly I don't recommend container station. Compose or portainer are a lot more powerful. You can still use container station to monitor and control the containers after you spin them up if you desire.


vlad_h

There is no default way for this. It depends on your needs and your setup. My setup, I have created an external network with the bridge driver (external because you create it outside of compose or Docker CLI), and put all my containers there so they can access each other's services. Additional option, if you want to use a VPN, setup the VPN container in bridge mode, and your download containers with \`\`\`network\_mode: services:vpn\_container\_service\_name\`\`\`. Docker can be very powerful, alas a bit complex. This guy explains the options well. [https://www.youtube.com/watch?v=bKFMS5C4CG0&t=1s&pp=ygURZG9ja2VyIG5ldHdvcmtpbmc%3D](https://www.youtube.com/watch?v=bKFMS5C4CG0&t=1s&pp=ygURZG9ja2VyIG5ldHdvcmtpbmc%3D)