Automate Marketing Initiatives with Salesforce Marketing Cloud Learn More

How to remove machine dependency for LAMP development using Docker?

Being a developer, sooner or later you have to undergo such machine dependency problems while deployment of code on the server. There are scenarios where you have to work with a team of developers and maybe they use different versions of PHP and MySQL, or if you are working for LAMP environment then WAMP, XAMPP, LAMPP, MAMP installation can be a big pain for developers.

 

Now, let’s assume you are done with all installation but what will happen if the server environment does not match with your local development environment? I know this is the most undesirable situation for any developer. But, do you know you can get rid of all these hitches and save your development time? There are a number of solutions available in the market. But, here I want to share my personal experience with Docker.

 

My experience with Docker has been quite good, I have been using Docker for 3 years now. Docker, which initially released 5 years back has filled the gap and offered a consistent development environment to the developers. Before using docker, as a full stack developer, while working on LAMP environment, I always had to switch my PHP, Apache, MySQL settings and versions, when I switched to multiple projects. It was a big pain to repeat the set every time and it ultimately affected my productivity. But, Docker has made things easier and faster.

 

Let me explain you with an example:

If I want to set up my development environment for PHP 7.2, Mysql mysql:5.7.22 and Nginx server.

I have multiple solutions to setup this environment:

  • First, I can install XAMPP/WAMP/LAMPP, but this environment does not contain Nginx service.
  • Second, I can install everything separately in the local machine, but there are many problems with this process too.

Problem 1

If your development machine is Windows and deployment server is Ubuntu or vice-versa.

Problem 2

Development software compatibility installation is a critical time consuming process for the developer.

Problem 3

Even if you solve both of these problems, you will have to change settings according to your project’s requirements and it will take a long time to execute those changes.

That’s where Docker comes to the rescue, it not only simplifies all these problems but simply removes all machine dependency problems.

How to install Docker?

Using Docker does not require any professional courses or training. If you have a basic understanding of development environment setup, you can easily do it . You just have to install Docker in your machine or on the server and simply let it manage everything right from the development to the deployment. With Docker, you can create any number of virtual machines and keep those into a single container.

You can find a complete Docker installation guide here with this link https://docs.docker.com/install/ from where you can select your OS and install. Docker uses the concept of container and images. Now let’s understand what is Docker’s container and images.

Docker Images, Layers and Containers

Docker images are basically the files with the set of instructions, consisting of multiple layers that can be used to incorporate tools, system library and other files required for executable code. When we run an image, it becomes one or multiple instances for the container. The Docker image includes all dependencies of the executable code so that the containers can run independently from one environment to another in a similar OS without any changes. You can have multiple containers for a single image.

  • If you want to see the list of all running Docker containers you have to execute the command
    docker ps-a
  • If you want to see all running images you have to execute the command
    docker images –a

You must have basic knowledge of command execution as Windows operating system uses power shell to execute the commands and Ubuntu and Mac OS use the terminal to execute the commands.

How to set up XAMPP machine using Docker?

Before setting up XAMPP machine, make sure you already have Docker installed in your machine.

Now first create a directory anywhere in your system.

 

Directory structure (I have created this directory according to my requirements, you can create according to your requirement):

 

  • mysql (directory)
  • nginx (directory)
  • php (directory)
  • docker-compose.yml file)
  • Dockerfile (file and it does not contain file extension)

What is docker-compose.yml ?

 

Compose is a tool for defining and running multiple-container Docker applications. With Compose, you can use a YML file to configure your application’s services. Define the services that make up your app in docker-compose.yml, so they can be run together in an isolated environment.

 

What is Dockerfile?

 

A Dockerfile is a text document that contains all the commands a user can call on the command line to assemble an image.

Using docker build, users can create an automated build that executes several command-line instructions in succession. Following are the commands that you can use in a Dockerfile.

  • Mysql directory: Put your customized MySQL conf file if you have customized anything.
  • nginx directory: Put your customized nginx conf file if you have customized anything.
  • PHP directory: Put your custom php.ini file if you have customized anything.

Note:

Make sure the path of above-mentioned files are currently written in docker-compose.yml

You can navigate here <ahref=”https: github.com=”” osingh152=”” docker-with-php-mysql-nginx”=””>https://github.com/osingh152/docker-with-php-mysql-nginx and find the sample files for docker-compose.yml and Dockerfile</ahref=”https:>

A place for big ideas.

Reimagine organizational performance while delivering a delightful experience through optimized operations.

How to PHP application using Docker in Laravel?

Let’s explore how we can use Docker container with php 7.2. , MySql 5.* and NGINX server. Change nginx file for laravel public folder. The path for Laravel: root /var/www/public;

 

Other: root /var/www;

 

/var/www -> This is a Path of the working directory

 

Before moving to the next step please make sure you have installed Docker in your machine

Command to check Docker Version-docker –v

 

Please follow the below mentioned steps and commands to use docker

  • First, you have to clone the project in your specific drive or directory
  • Now Install docker and docker compose in your machine
  • Open power shell
  • Navigate to your project directory, refer step 1.
  • docker-compose up -d
Essential Docker Commands

 

1. Start all required containers:docker-compose up -d

-d: Run the container in the background

2. Stop all container:docker-compose down

3. Run commands in a specific container:docker-compose exec app nano .env

docker-compose exec – This is a command to execute commands

app – This the name of the container in which we want to run the command

4. Accessing MySql:docker-compose exec db bash

After entering db bash hit mysql -u root -p for MySQL root password and default database refer docker-compose.yml file

Hope this article will help you to have the basic understanding and usability of the Docker and provide you with a solution for machine dependency problem while development to save your time and increase your productivity.

Top Stories

The Complete Guide to Odoo in 2026
The Complete Guide to Odoo in 2026: Implementation, Customisation, Integration, Migration and Cost
What Odoo actually is Odoo is a suite of business applications built on a shared database — CRM, sales, inventory, manufacturing, accounting, HR, website, point of sale, and several dozen more. The applications are modular. You switch on the ones you need and leave the rest off. The architectural point
How to Connect WooCommerce to Odoo
How to Connect WooCommerce to Odoo — Complete Setup Guide
Connecting WooCommerce to Odoo does not require a developer, a middleware tool, or weeks of implementation. The Zehntech Odoo WooCommerce Connector gives you real-time bi-directional sync between your WooCommerce store and your Odoo backend — set up in under 15 minutes. This guide is for Odoo administrators, eCommerce operations managers,
How to Connect Odoo to ShipStation — Step by Step Setup Guide
How to Connect Odoo to ShipStation A Step-by-Step Setup Guide
This guide walks you through connecting Odoo to ShipStation using the Zehntech Odoo ShipStation Connector — from generating your API credentials in ShipStation to your first automated order push and tracking import. Most setups take under 10 minutes. Prerequisites Before you begin: Odoo version: v17, v18 or v19 (Online, Odoo.sh
AI Agents Are Transforming Odoo ERP Operations in 2026
How AI Agents Are Transforming Odoo ERP Operations in 2026
Most ERP systems already hold the information needed to make better decisions. The problem is the work between the data and the decision: opening several modules, filtering records, exporting spreadsheets, comparing numbers and then updating Odoo manually. AI agents are beginning to remove that gap. Unlike a chatbot that only
Connect Odoo & Shopify Automatically in 2026
How to Connect Odoo and Shopify Automatically (2026 Guide)
If you're running Shopify for your storefront and Odoo for everything behind it — inventory, accounting, fulfillment — you already know the two don't talk to each other out of the box. This guide walks through exactly how to connect them so orders, stock, and customer data sync automatically, with
Odoo Hubspot Connector
How to connect hubSpot to odoo a step-by-step setup guide
This guide walks you through connecting HubSpot to Odoo using the Zehntech Odoo HubSpot Connector from generating your API key in HubSpot to your first live sync. Most teams complete this in under 10 minutes. Prerequisites Before you begin: Odoo version: v16, v17, v18 or v19 (Online, Odoo.sh or On-Premise)

          Success!!

          Keep an eye on your inbox for the PDF, it's on its way!

          If you don't see it in your inbox, don't forget to give your junk folder a quick peek. Just in case.



              You have successfully subscribed to the newsletter

              There was an error while trying to send your request. Please try again.

              Zehntech will use the information you provide on this form to be in touch with you and to provide updates and marketing.