I have a unchangeable docker image. It bind one port and cant change it. This image also need an Internet connection. I need to run many containers. To access Internet via Docker I use hetwork=host, but in this case can run only one - all another got Address already in use. So I need not use network=host, but container must have Internet. And if all ok I can use simple -p 8080:any_my_port. How I can run it? Docker with internet but without network host
CodePudding user response:
All docker images are immutable.
You don't need --network=host
for containers to access the internet, and you certainly don't need port forwarding with that option, either.
If you want to fix the "address in use" error and have outgoing internet access from the container, remove that flag. Unless there's something special about this container, you can rebind different host ports to the container exposed port (or use -P
without additional options, and that'll do it for you)
If you want to have incoming network traffic to the service in the container, only then you need the -p
flag, and if you want access from the internet, you'll need to configure your LAN router to port forward to your host computer