What's wrong with this dockerfile

What’s wrong with my dockerfile?
The dockerfile is in the rootfolder of my repo and the dist-folder too.

FROM nginx

# copy folder
COPY dist /usr/share/nginx/html

EXPOSE 8080
CMD ["nginx"]

I build the image:

  • version control, apt (and Docker)
  • mesos slave failed to excute docker command
  • “Error response from daemon: Cannot start container … no such file or directory” on Oracle Linux running hello-world
  • How to get root privilege in Docker container?
  • Add Docker Machine to Swarm cluster after creation
  • Docker Data Volume Container - Can I share across swarm
  • docker build -f Dockerfile.nginx -t localhost:5000/test/image:${version} .
    

    The image is there after performing docker images

    It looks so simple but when I try to run the image as a container:

    docker run -d -p 80:8080 localhost:5000/test/image:15
    545445f961f4ec22becc0688146f3c73a41504d65467020a3e572d136354e179
    

    But: Exited (0) About a minute ago

    The docker logs shows nothing

  • Is it possible to run a command when stopping a Docker container?
  • Issue when I try to create a docker image [duplicate]
  • How to start Docker daemon inside a Docker container using supervisord?
  • Copy all files with given extension from docker container
  • Debian Docker config file
  • In the perspective of runtime performance, is Docker running on cloud services efficient?
  • 2 Solutions collect form web for “What's wrong with this dockerfile”

    Default nginx behaviour is run as a daemon. To prevent this run nginx with parameter daemon off.

    CMD ["nginx", "daemon off"]
    

    By default, Nginx will fork into the background and — as the original foreground process has terminated — the Docker container will stop immediately. You can have a look at how the original image’s Dockerfile handles this:

    CMD ["nginx", "-g", "daemon off;"]
    

    The flag -g "daemon off;" causes Nginx to not fork, but continue running in the foreground, instead. And since you’re already extending the official nginx image, you can drop your CMD line altogether, as it will be inherited from the base image, anyway.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.