问题
I have a docker image which is running perfectly in file I have done
EXPOSE 8080
and I run my image using
sudo docker run -p 8080 <image-name> <Argument1> <Argument2>
Image runs but when I go to
localhost:8080
I get page not found error. Is there no way I can see some response or something on localhost:8080?
回答1:
The option -p 8080 will expose the container:8080 port into a host:random-port.
The option --publish works as follow: -p ip:hostPort:containerPort. Using a -P| --publish-all will automatically bind any container-opened port into random-host port.
It is also possible to publish range of ports: -p 1234-1236:1222-1224.
来源:https://stackoverflow.com/questions/35478241/docker-image-not-exposing