See https://github.com/moby/moby/issues/3465 - Due to Dockerfile limitations it's not possible to remove exposed ports when extending a base image. It would be nice to have a Docker image specifically designed for building more complex ones, without the default port 80 exposed, e.g. removing this line https://github.com/nginxinc/docker-nginx/blob/97b65112180e0c7764465aa47a974fc7af3c99ae/mainline/stretch/Dockerfile#L95