How can I expose my tomcat server outside of my docker container running on my local machine?

Stephen D :

I am unable to access my tomcat server that is started from, inside of my docker container. I am running the docker container from my local windows machine. I cannot hit it with my browsern or curl. Below are the commands I had used.

docker run 535b29035275 -p 9080:9080

01:41:18.177 INFO main c.m.i.ServerStart - Starting ServerStart v0.1.0 on 8bfe44c70af0 with PID 1 (/MainServer/target/mainserver-0.1.0.jar started by root in /)

01:41:19.619 INFO main o.s.b.w.e.t.TomcatWebServer - Tomcat initialized with port(s): 9080 (http)

docker ps

8bfe44c70af0        535b29035275        "java -jar MainServe…"   5 minutes ago       Up 5 minutes        9080/tcp            gracious_euler```


$ curl localhost:9080
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:--  0:00:02 --:--:--     0

shy4blue :

run command syntax:

docker run [OPTIONS] IMAGE[:TAG|@DIGEST] [COMMAND] [ARG...]

[OPTIONS] must be before the IMAGE.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=308585&siteId=1