Junior — Middle
What are the differences between 'git merge' and 'git rebase' when integrating changes into a branch?
sobes.tech AI
Answer from AI
The EXPOSE command in Dockerfile is used to document which ports the container listens on at runtime. It indicates that the application inside the container is listening on these ports.
However, EXPOSE itself does not publish the ports to the host. To do that, you need to use the -p or --publish option when running the container.
Example:
FROM nginx
EXPOSE 80
This indicates that the container listens on port 80. When running the container, you can map this port to a port on the host:
docker run -p 8080:80 my-nginx-image
Thus, EXPOSE helps to document and understand which ports are used, and facilitates container interaction.