Skip to content

Instantly share code, notes, and snippets.

@aurelijusb
Last active February 18, 2019 18:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aurelijusb/6f6b1c86c440ce527250193ffcae62d7 to your computer and use it in GitHub Desktop.
Save aurelijusb/6f6b1c86c440ce527250193ffcae62d7 to your computer and use it in GitHub Desktop.
KaunasPHP v.52: Simple dockerized PHP application

Run simple PHP application in docker

  • Install docker
  • Download example files: (Dockerfile, index.php)
  • Run in terminal:
docker build . -t kaunasphp-example
docker run -p 8080:80 kaunasphp-example

This will build docker container named/tagged kaunasphp-example. Docker client will download all necessary files by the configuration in Dockerfile. . is the name of current path where Dockerfile exists.

Second line runs container (tagged as kaunasphp-example) itself. 80 port is usually already used in many computers, so forwarding host 8080 port to container 80.

After those commands you should see:

Hello from docker. PHP version: 7.2.11

when opened http://127.0.0.1:8080/ in a browser

Useful commands

docker ps to list running containers

FROM php:7.2-apache
COPY . /var/www/html/
<?php
echo 'Hello from docker. ';
echo 'PHP version: ' . phpversion();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment