Deploy your website with a Docker Apache httpd container volume

2022-06-16 00:55:42 By : Ms. LUCKY CHAN

Community driven content discussing all aspects of software development from DevOps to design patterns.

You don’t need to copy all of your website’s files into a dockerized Apache httpd image to test your website with Docker, especially if all of your website’s files are on a local hard drive.

There’s a much simpler approach, one that is especially useful for testing on your local machine. Simply run the official Apache httpd Docker image locally and create a Docker volume that points to files on your local machine.

The benefits of this approach include:

To run an Apache httpd Docker container with a volume mapping that points to the local file system, simply issue a docker run command with these attributes:

The command to run the dockerized Apache https service with local files is as follows:

Note: you may run into an invalid reference format error when the above docker run command is run in PowerShell. You may have better luck with this version on Windows:

The invalid reference format error happens when the Docker command does not properly process the $PWD variable. You may need to put the $PWD variable within curly braces to make the Docker Apache run example work on Windows.

In this example, a Dockerfile is not required to create a custom httpd Docker image. Files are read from the local file system through a mapped Docker volume.

When a Docker volume mapping isn’t performed, anything inside the Apache httpd container’s htdocs folder is served up over the web when the server runs.

Here is the full path to the Apache htdocs folder inside the Docker httpd image:

In the docker run command the /website/ folder, which is in a sub directory of the present working directory (PWD) in which the docker run command was issued, maps to the Apache container’s htdocs folder:

When the Docker httpd container runs, Apache serves files from the present working directory’s /website directory. It uses the local file system of the host machine instead of the container’s internal htdocs folder.

When the Apache Docker httpd container runs, local files are loaded and accessible on the localhost address.

With this configuration, you can add, update and delete files locally, and the Docker httpd image updates your website immediately. There is no need to create a new image, redeploy your Docker hosted web application, or even stop and start the Docker httpd service.

Sometimes it is necessarily to build a custom Docker http image with all of your website filed copied into the container’s internal htdocs folder. But for local development and testing, a simple volume mapping is more than sufficient.

Tools for enterprise architects get criticized for their complexity, but they are getting better. A recently released module from...

Observability helps developers and IT operations teams identify and fix system issues. And with the right setup, it can improve ...

As distributed software systems grow in scale and complexity, things like monitoring and debugging can become a tangled mess. ...

To be successful with low-code adoption, organizations must clearly define project goals, ensure the right mix of staffing and ...

Tabnine's code completion assistant adds support for 11 languages with a major AI overhaul.

Experts weigh in on which in-demand programming languages offer the best job prospects.

Alfa Romeo F1 Team Orlen uses Zadara to store and access race and technical data so that it can improve race analysis and ...

FinOps practices can guide an organization toward more effective cloud cost management. How much do you know about key FinOps ...

How do you choose the cloud programming language that best suits your current and future needs? Explore 11 popular options and ...

Orca Security discovered that inadequate tenant separation in Microsoft's Azure Synapse service could allow a threat actor to ...

As organizations become more cloud-centric and adapt to remote work, a new technique known as security service edge is gaining ...

Researchers say a critical flaw in the Atlassian Confluence Data Center and Server is now being used to spread ransomware in the ...

Many organizations struggle to manage their vast collection of AWS accounts, but Control Tower can help. The service automates ...

There are several important variables within the Amazon EKS pricing model. Dig into the numbers to ensure you deploy the service ...

AWS users face a choice when deploying Kubernetes: run it themselves on EC2 or let Amazon do the heavy lifting with EKS. See ...

All Rights Reserved, Copyright 2000 - 2022, TechTarget Privacy Policy Cookie Preferences Do Not Sell My Personal Info