Create your own PHP application with built-in PHP web server
Go to Project 3 from the git repository root:
. ├── Dockerfile └── www └── index.php
Build an image:
docker build -t localhost/p03_php .
Start the container:
docker run -d --name p03_php -p "8080:80" localhost/p03_php
Open in a web browser and reload the page multiple times. You can see the output is different each time with more lines.
Now delete the container. Probably you already now how, but as a reminder I show you again:
docker rm -f p03_php
Execute the “docker run …” command again and reload the example web page to see how you have lost the previously generated lines and delete the container again.
Now start the container with a volume to preserve data:
docker run -d --mount source=p03_php_www,target=/var/www --name p03_php -p "8080:80" localhost/p03_php
This way you can delete and create the container repeatedly a you will never lose your data until you delete the volume. You can see all volumes with the following command:
docker volume ls # or docker volume list
After you have deleted the container, you can delete the volume:
docker rm -f p03_php docker volume rm p03_php_www