4

I want to share my host with container.

I already have some services running in containers, e.g. Redis.

I want to run another app in another container. The app expects that Redis is listening on localhost:6379.

From my host machine, I have an access to that port, because I have a port mapping from the Redis-container port to the host port.

I want my app container to have access to the same ports and networks that my host machine has.

I tried this command: docker --network=host run somecontainer but got unknown flag: --network so no success. SO question, Docker docs.

How else I can achieve the behavior described above? Host localhost = container localhost

Maksim Nesterenko
  • 5,661
  • 11
  • 57
  • 91

1 Answers1

9

You inverted the parameters and docker is trying to resolve the flag when no command is given (you can see with docker --help that --network is not listed)

docker run --network ... will work better! :-)

Don't forget that --network is a flag for the run command, run must precede.

TLDR: docker run --help and docker --help are different, errors happen.

Fabien
  • 4,862
  • 2
  • 19
  • 33