Remote access to webserver in docker container

前端 未结 4 647
有刺的猬
有刺的猬 2020-12-28 23:44

I\'ve started using docker for dev, with the following setup:

  • Host machine - ubuntu server.
  • Docker container - webapp w/ tomcat server (using https).<
4条回答
  •  孤独总比滥情好
    2020-12-29 00:36

    I figured out what I missed, so here's a simple flow for accessing docker containers webapps from remote machines:

    Step #1 : Bind physical host ports (e.g. 22, 443, 80, ...) to container's virtual ports. possible syntax:

        docker run -p 127.0.0.1:443:3444 -d 
    

    (see docker docs for port redirection with all options)

    Step #2 : Redirect host's physical port to container's allocated virtual port. possible (linux) syntax:

        iptables -t nat -A PREROUTING -i  -p tcp --dport  -j REDIRECT --to-port 
    

    That should cover the basic use case.

    Good luck!

提交回复
热议问题