0

I'm simply trying to get my dockerfile to point to a specific directory so that when I go to the URL I can do something like this: localhost:80/ask.PNG, and that image will render in the browser.

Currently my Dockerfile builds and runs, but when I try the above it states the files don't exist. Here is what I have.

FROM httpd:2.4
COPY / /MyPath/imagesfolder

The imagesfolder is saved within the same folder as my dockerfile and contains a few different images.

Jordan Davis
  • 855
  • 3
  • 15
  • 22

1 Answers1

1

According to hub.docker.com/_/httpd/ you have to do something like this:

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

You must copy your files to the specific location from which httpd is going to serve them and this is /usr/local/apache2/htdocs. Put your files there and it will work.


Example

My folder structure (Dockerfile is the same with the above):

~/docker_tests/httpd$ tree
.
├── Dockerfile
└── public-html
    ├── 1.jpg
    ├── 2.jpg
    └── 3.jpg

1 directory, 4 files

Build and run ...

docker build -t my-apache2 .
docker run -dit --name my-running-app -p 8080:80 my-apache2

Access your files at

http://localhost:8080/1.jpg
http://localhost:8080/2.jpg
http://localhost:8080/3.jpg
tgogos
  • 23,218
  • 20
  • 96
  • 128