I started use Docker containers for development but my challenge was to see the code changes in the Docer container when I was using WSL Ubuntu. I was using Docker Inside the WSL Ubuntu. I was running into problems because I had to rebuild to see my changes and that was not practical.

The purpose of this page is to show you to create a PHP app in a Docker container where you can refresh the page and reload after you have edited and changed the application code.




Finally I found the solution from this video and follow these steps:

1. Create a project with VSCODE

Start a wsl terminal and cd into:

cd /mnt/f/apachefriends/xampp/htdocs/PHP/docker-azure/php-simple

2. Dockerfile:

FROM php:8.2-cli
COPY . /usr/src/myapp
WORKDIR /usr/src/myapp
CMD [ "php", "./index.php" ]

3. index.php

echo "hello from docker";

4. Build

$ docker build -t my-php-app .

5. Run

$ docker run -d -p 80:80 --name php-app-webserver-2 -v /mnt/f/apachefriends/xampp/htdocs/PHP/docker-azure/php-simple:/var/www/html php:8.1-apache

Note the -v flag. This option is for volume - More information here about Volumes

6. Open in Browser:




  1. https://www.youtube.com/watch?v=ThpnqYpvnIM
  2. https://hub.docker.com/_/php