Docker Book: Difference between revisions

From Rixort Wiki
Jump to navigation Jump to search
No edit summary
Line 29: Line 29:
* Visit localhost:8000 in browser
* Visit localhost:8000 in browser
* Ctrl+C terminates container and Docker will remove it automatically due to the <code>--rm</code> flag
* Ctrl+C terminates container and Docker will remove it automatically due to the <code>--rm</code> flag
[[Category:Docker]]

Revision as of 13:16, 9 June 2021

Notes for upcoming book on Docker

Installing Docker

  • Point to instructions on Docker website, no point in duplicating these
  • Make sure you are running the latest version

Hello World

  • docker run --rm hello-world
  • Include example output for checking
  • Explain use of --rm flag - without this we end up with lots of stopped but not removed images

Basic PHP example

  • docker run --rm php:7.4-apache-buster php -v, show output

Dockerfile:

 FROM php:7.4-apache-buster
 COPY index.php /var/www/html/index.php

index.php:

 <?php phpinfo();
  • docker build -t phpinfo:latest .
  • docker run --rm -p 8000:80 phpinfo
  • Visit localhost:8000 in browser
  • Ctrl+C terminates container and Docker will remove it automatically due to the --rm flag