The reason of the behavior is that the apache image you are using (https://hub.docker.com/r/nimmis/apache/, right?) is a plain apache without php support. So it just serves your php code as plain text.
You don't need two images in this case. Instead you need one image running Apache with php module. You can use the official php image (https://hub.docker.com/_/php/).
Your Docker file can look like this:
``` # see https://hub.docker.com/_/php/ FROM php:5.6-apache # copy your source into the /var/www/html inside the container COPY . /var/www/html/ ```
Now you can build and run it like this
``` docker build -t apache-foo-docker . docker run -d -p 8080:80 -v $(pwd):/var/www/html --name apacheFoo apache-foo-docker ```