What is the difference between "expose" and "publish" in Docker?
@lebyy▲ 0 net votes
Problem: I'm experimenting with Dockerfiles, and I think I understand most of the logic. However, I don't see the difference between "exposing" and "publishing" a port in this context. All the tutorials I have seen first include the EXPOSE command in the Dockerfile:… Fix (from the top answer): Basically, you have three (four) options: Neither specify EXPOSE nor -p Only specify EXPOSE Specify EXPOSE and -p Only specify -p which implicitly does EXPOSE If you specify neither EXPOSE nor -p , the service in the container will only be accessible from inside the container itself. If you EXPOSE a port, the service…