DEV Community

Cover image for Hosting site on httpd and nginx docker container
Sami Ullah Saleem for AWS Community Builders

Posted on

Hosting site on httpd and nginx docker container

Docker Project
In this project, I created containers using httpd and nginx images using command

~ docker pull httpd
~ docker run --name httpdproject httpd -d
Enter fullscreen mode Exit fullscreen mode

Then I first stop and then remove this container

* docker stop httpdproject 
* docker rm httpdproject 
Enter fullscreen mode Exit fullscreen mode

Then I mount my website content on my container using these commands

~ docker run --name mywebproject -p 8080:80 -v $(pwd)/web:/usr/local/apache2/htdocs:ro -d httpd
~ docker ps 
Enter fullscreen mode Exit fullscreen mode
  • We can check our website will be running on 8080 port which it's redirecting to 80 port of container

Same Process, we will do with nginx

~ docker run --name nginxproject -p 8082:80 -v $(pwd)/web:/usr/share/nginx/html:ro -d nginx
Enter fullscreen mode Exit fullscreen mode

Now, we can see our site will be working on 8082 port.

Dictionary
ps command to check running containers
images command to see available images
-p this flag with run use for port redirecting
-v is used to mount volume on the container
--name flag with run is used to name our container
-d flag means run container in detached mode. It means that it should be run in the background

Top comments (0)