How to access tomcat running in docker container from browser?

前端 未结 5 1504
盖世英雄少女心
盖世英雄少女心 2020-12-05 05:00

I am running tomcat in my docker container from the Official Repo.

docker pull tomcat

And as per guidelines stated in the homepage I\'ve ru

相关标签:
5条回答
  • 2020-12-05 05:21

    option -p has argument hostPort:containerPort so in your case port 8080 (inside your docker image) is mapped to port 8888 on the host (your windows box). This means you should be able to find the tomcat on your Windows box by appending :8888 to your URL, just like you did with curl.

    0 讨论(0)
  • 2020-12-05 05:21

    Using docker-machine ls to get the IP of the Virtual Box instance running the container. Then use that with the associated port you exposed, in my case 8080, so it was http://192.168.99.100:8080.

    0 讨论(0)
  • 2020-12-05 05:32

    Seems there's a better answer available since Docker-Tools was introduced a few months ago. If you're not using Docker Tools, take a look at https://docs.docker.com/machine

    If you are using Docker Tools,

    1. find the docker machine name with $ docker-machine ls
    2. find the docker IP address with $ docker-machine ip <machine-name>
    3. use the ip address to connect, e.g. $ curl 192.168.99.100
    0 讨论(0)
  • 2020-12-05 05:33

    run boot2docker ip to get the IP of your docker bridge. Then you can run curl BRIDGE_IP:8888 The IP will be something like 192.168.59.103. With boot2docker the VMs networking stack is not your local host but running on a virtual interface.

    0 讨论(0)
  • 2020-12-05 05:37

    You may be missing a port forwarding rule in the VirtualBox settings.

    boot2docker vm > settings > Network > NAT adapter > Port forwarding
    

    Note the last entry:

    enter image description here

    This way you have configured the whole chain: hostPort:virtualBoxPort then virtualBoxPort:containerPort, as shown in the following diagram: enter image description here

    0 讨论(0)
提交回复
热议问题