DEV Community

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

Posted on

1

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

Image of Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

Top comments (0)

Best Practices for Running  Container WordPress on AWS (ECS, EFS, RDS, ELB) using CDK cover image

Best Practices for Running Container WordPress on AWS (ECS, EFS, RDS, ELB) using CDK

This post discusses the process of migrating a growing WordPress eShop business to AWS using AWS CDK for an easily scalable, high availability architecture. The detailed structure encompasses several pillars: Compute, Storage, Database, Cache, CDN, DNS, Security, and Backup.

Read full post

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay