Hands-on task
EXPOSE doesn't publish a port
A colleague built the catalog:1 image from /root/catalog and started the catalog container with the -P flag: "the Dockerfile has EXPOSE, the port will be published by itself". Docker did hand out a port on the host (docker port catalog), but the page doesn't open on it.
Figure it out and fix it:
EXPOSEin/root/catalog/Dockerfilemust describe the port the service actually listens on;- the
catalog:1image is rebuilt from the fixed Dockerfile; - the
catalogcontainer runs from the new image, and the service is published on the server's127.0.0.1:8090.
The image builds without the internet: the base busybox:1.36 is already available locally. The legacy builder is deprecated warning during the build is not an error.
- EXPOSE
- docker build
- docker run -p