0

I start a Docker container on my machine. It will have to talk to two services on remote nodes and for this it occupies ports 80 and 443.

I log into the container and start one task from the command line. The task does some initial data exchange with the remote nodes. Having done that, it starts a very long computation without any need to contact the remote nodes anymore.

I'd like to run that task more times in parallel, but I cannot start multiple instances of the container, because they would clash about the ports.

Is there some kind of software router that I can use to sort out this problem?

I know from here that I can run multiple shells on my container, but I am still curious about the possibility of using a software router to serve multiple containers.

NB: I am not using any docker-compose or kubernetes setting. Just plain, simple containers.

Marco Faustinelli
  • 3,734
  • 5
  • 30
  • 49
  • How does your container accept _inbound_ connections on these ports? – David Maze Nov 25 '22 at 20:44
  • @DavidMaze Just outbound HTTP requests. – Marco Faustinelli Nov 26 '22 at 14:12
  • 1
    If you're only making outbound requests, you don't need to "occupy" ports; delete any `docker run -p` or Compose `ports:` options. These are only needed for inbound requests, and if you delete these options, then there won't be a conflict between multiple containers. – David Maze Nov 26 '22 at 16:55
  • @DavidMaze - I reckon this is a Docker improvement. I wasn't aware of it. Thank you. Which Docker version introduced this? And again: if my algorithm contained inbound calls, is there a routing solution for running many of them? – Marco Faustinelli Nov 28 '22 at 08:25
  • 1
    You've only needed published ports for inbound connections at least as long as I've been using Docker, before they switched to date-based release numbers, and before the Docker 1.13 you still very occasionally see in the wild. – David Maze Nov 28 '22 at 11:15

0 Answers0