Follow these steps to create a Web Server using Docker


  1. Make a directory in terminal using these commands:
    • mkdir /test
      cd /test

  2. Now create a file `Dockerfile` (File name is hard coded do not change the file name)
    • touch /test/Dockerfile

  3. Create a sample web page with name index.html
    • vi /test/index.html

  4. Edit the file using following instructions
    • vi Dockerfile
      FROM centos:latest
      MAINTAINER NewstarCorporation
      RUN yum -y install httpd
      COPY index.html /var/www/html/
      CMD [“/usr/sbin/httpd”, “-D”, “FOREGROUND”]
      EXPOSE 80

  5. Build the image using docker build. Test is the directory where Dockerfile is present and –t option is to tag or name the image. After building Run the docker image.
    • docker run –dit –p 1234:80 webserver:v1

  6. To See the Result on web browser
    • Type "http://:1234/" on your web browser.

    To know more methods on creating web server using docker, you can refer : https://medium.com/@vi1996ash/steps-to-build-apache-web-server-docker-image-1a2f21504a8e