I’m experimenting with dockerfiles and the use of expose and publish has been a major confusion.
In all the tutorials they first include the EXPOSE command in the dockerfile and then build an image from this dockerfile
$ docker build -t an_image - < Dockerfile
And then publish the same port as above when running the image
$ docker run -d -p 8080 an_image