- Create a directory (ex. php-demo)
- Create Dockerfile in root
$touch Dockerfile
FROM php:latest ## Pull the image from dockerhub COPY index.php /var/www/html/index.php ## Copy file index.php to directory /var/www/html in image. EXPOSE 80 ## Port 80 is exposed for apache. CMD ["usr/sbin/apache2ctl", "-D", "FOREGROUND"] ## Apache started the container.
These lines of code represent the image we're going to use along with copying the contents of the current directory into the container.
docker build -t php-demo:latest .
docker run --name first-php-app -p 9090:80 -d first-app:latest
docker images ls
curl localhost:9090