Search code examples
dockerportportforwardingkubernetes

Is it possible to set a different host port than the container's exposed port in docker?


Is it possible to set a different host port than the container's exposed port in docker? For example docker run -name some_container -p 80:8080 -i -t some_img If so, is it -p host:container or -p container:host? I've looked through the docs and haven't found any examples of this nor details on the publish option for docker run.

Additionally, I don't want to use the same port as the container because that is where Kubernete's api-server is listening.


Solution

  • It is host:container and it is possible to set different port on the host. This Link has some good examples.