Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Docker Image of the Day: Apache httpd

DZone's Guide to

Docker Image of the Day: Apache httpd

On the Docker Hub there’s many prebuilt images already. As a quick example, let’s use the Apache httpd image and build a container that runs httpd and serves an example webpage.

· Cloud Zone
Free Resource

Download this eBook outlining the critical components of success for SaaS companies - and the new rules you need to play by.  Brought to you in partnership with NuoDB.

I have a getting started post on Docker already, so I thought it would be useful to pull together some of the simplest possible examples of building and running Docker containers, as real examples.

On the Docker Hub there’s many prebuilt images already. As a quick example, let’s use the Apache httpd image and build a container that runs httpd and serves an example webpage.

This is pretty much the instructions that are on the httpd image page, so no surprises here.

In a new folder, create a Dockerfile:

FROM httpd:2.4
COPY ./public-html/ /usr/local/apache2/htdocs/

Create an index.html file in public-html and put some "hello world" content in it.

Next, from a Docker Quickstart Terminal, cd into the folder when you created the Dockerfile and public-html, and build your image:

docker build -t imagename .

Now, to start up a container based on your image called imagename (name it whatever you like), and expose port 80 on the container to port 80 to the outside world:

docker run -it -p 80:80 imagename

Now, point a browser at the IP of your docker machine (displayed when Docker Quickstart starts up), and success, you should see your html being served from Apache in your container!

If you’re on Windows, the equivalent to capture the tty output is:

winpty docker run -it -p 80:80 imagename

Learn how moving from a traditional, on-premises delivery model to a cloud-based, software-as-a-service (SaaS) strategy is a high-stakes, bet-the-company game for independent software vendors. Brought to you in partnership with NuoDB.

Topics:
devops ,docker ,apache httpd

Published at DZone with permission of Kevin Hooke, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}