简体   繁体   中英

How to expose a Docker container

I have this Dockerfile written.

FROM python:3.6

WORKDIR /usr/src/app

EXPOSE 8080

CMD [ "python3", "-m http.server" ] //even tried CMD [ "python3", "-m", "http.server" ]

I built the image with this:

docker build -t --name server .

and I ran a container from the image like this:

docker run -d -p 8080:8080 --name web server

But when I hit < host-url >:8080

It doesn't work.

Can somebody please help me?

You are trying to run the Python SimpleHTTPServer which is served in port 8000 by default.

Either your Dockerfile should expose 8000 instead of 8080

EXPOSE 8000

Or, change the command to run it in port 8080

CMD ["python3", "-m",  "http.server", "8080"]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM