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:

  • HAProxy over SSL with RabbitMQ SSL authentication + Kombu client - IOError('Socket Closed')
  • docker mysql persistent storage
  • Docker Commit Created Images and ENTRYPOINT
  • Tomcat 7 fails when starts in Debian, but continue working in background
  • Setting up an ADFS identity provide using Docker/Vagrant
  • How to setup docker to use cache from registry on every build step
  • 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

  • Docker - Couldn't connect to Docker daemon
  • Add new Tomcat containers behind Apache with Docker
  • How can I connect my docker to the internet?
  • ASP.Net VNext after dnu publish not working on linux machines
  • What is the proper way of deploying versioned applications with docker?
  • command not found when running in docker bash script
  • 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.