We have a Magento 2 website and are trying to deploy the website as docker containers running in Kubernetes in GCP. At present, we have the website set up with a LAMP. So I believe we need to have the 'Dockerfile' and 'docker-compose.yml' file. Also, trying to set up using the Ubuntu 18.04 image. Would like to have an understanding of whether this is the correct way to dockerize a website?

Thank you in advance for the help.


There are many ready made docker containers for Magento 2 available. Once you are familiar with Docker and have built and tested the Magento containers you would simply need to migrate your existing Magento database, code and media to the container build. Ideally I would build a development Magento container environment running the same version of Magento 2 you are using in your live site.

The containers I have developed for development and production are based on the Ubuntu PHUSION docker base image :


This includes

  • PHP 7.4
  • Apache 2.4
  • MYSQL 5.7 / 8
  • Varnish 6
  • RabbitMQ
  • PhpMyAdmin
  • ELASTIC search 7.x

And has been tested with Magento 2.3.x and 2.4.x. I have not tried to deploy this environment with Kubernetes.

  • Thank you for the update. I already have a running magento2 website, which uses Apache 2.4, PHP 7.2, MySQL 5.7 version running in Ubuntu 18.04 and i am trying to create a docker image of this. I believe i have to create a docker-compose.yml and Dockerfile in order to dockerize this environment? Will it be possible to use the same 'docker-compose.yml' with slight modifications regarding the OS to use it this way. Is it possible to have a full docker image built and uploaded to google docker registry for the website and could be loaded when ever it is required? TIA. – Sandeep S Nov 5 '20 at 6:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.