You are here:>>How to install Docker and Dockerize PHP Application

How to install Docker and Dockerize PHP Application

Video Tutorial

In this post I will show you how to install and configure Docker on Linux and Dockrize a sample PHP application.

Please watch the video for detailed explanation and demo.

I will be using Amazon EC2 instance as my Docker host for this demo.

Docker Installation on Amazon Linux EC2 Instance

  • Login to AWS EC2 instance or any other system you wish to use as a Docker host using SSH.
  • Update repositories.

  • Install Docker

  • Start Docker

  • Add ec2-user to Docker group. Logout and login to SSH to activate group membership.

  • Display Docker info

PHP Sample Application Setup

  • Install GIT

  • PHP sample application GITHUB URL

  • Clone Git Repository


  • Create a file with name “Dockerfile” inside mydocker directory. Copy below contents to the Dockerfile and save it.

Build and Run Docker Image

  • Build new Docker image using below command

  • Display docker images

  • Start a Docker container based on the new image

  • Check container status using below command and make sure the status is UP

  • Access the application using below URL

Additional Docker Commands

  • Login to shell of Docker container using below command

  • Use below command to login to Docker Hub. Provide your Docker Hub username and password when prompted

  • Push your image to Docker Hub using below command

  • Pull Docker image from Docker Hub

  • Remove Docker image

  • Remove docker container

  • Remove all docker containers

That’s it guys, you now know how to install docker and build docker images and you have also seen how to run PHP applications inside your docker containers. please post a comment if you have any questions or suggestions.


About the Author:

I am a Senior Cloud Professional specialized in AWS Cloud with 11 years of IT experience. I am enthusiastic about Serverless Architecture. I am an expert in Oracle Fusion Middleware.

Leave A Comment