-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
27 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,49 @@ | ||
============================================================ | ||
Create your own PHP application with built-in PHP web server | ||
============================================================ | ||
|
||
Build an image: | ||
|
||
```bash | ||
docker build -t localhost/p03_php . | ||
``` | ||
.. code:: bash | ||
docker build -t localhost/p03_php . | ||
Start the container: | ||
|
||
```bash | ||
docker run -d --name p03_php -p "8080:80" localhost/p03_php | ||
``` | ||
.. code:: bash | ||
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: | ||
|
||
```bash | ||
docker rm -f p03_php | ||
``` | ||
.. code:: bash | ||
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: | ||
|
||
```bash | ||
docker run -d --mount source=p03_php_www,target=/var/www --name p03_php -p "8080:80" localhost/p03_php | ||
``` | ||
.. code:: bash | ||
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: | ||
|
||
```bash | ||
docker volume ls | ||
# or | ||
docker volume list | ||
``` | ||
.. code:: bash | ||
docker volume ls | ||
# or | ||
docker volume list | ||
After you have deleted the container, you can delete the volume: | ||
|
||
```bash | ||
docker volume rm p03_php_www | ||
``` | ||
.. code:: bash | ||
[Back to the main page](../../README.md) | ||
docker volume rm p03_php_www |