Strona przewinięta w 0 %
left arrow Back to blog

WordPress in Docker – why you should dockerize your WordPress site

WordPress in Docker - why you should dockerize your WordPress site - Develtio

The last decade’s introduction of Docker is considered one of the most significant breakthroughs in the world of software development. The possibility to package your app and its dependencies into convenient containers made developers’ lives so much easier. It’s not always possible nor recommended to utilize containerization, though in certain circumstances, using Docker considerably streamlines the development cycle. One such scenario is building a website with WordPress, which will be our main focus today. Read on to find out about the WordPress – Docker match made in… container.

What Is Docker?

Released in 2013, Docker is a toolkit that allows for creating and deploying applications with the help of virtual containers. Packaging apps and all their ingredients into the form of the container lets developers launch and test programs on different computers/servers regardless of their Operating System configuration and hardware. Basically, containerization helps developers write code without having to comply with production or testing environments.

The concept of containerization is slightly similar to virtualization. Virtual Machines (VMs) are designed to provide a complete emulation of hardware devices so that several OSs can be run from a single physical machine. Containers, on the other hand, provide virtualization of software layers placed above the host Operating System. Containers are much faster and resource-effective, but the VMs provide fully isolated environments and the ability to run multiple applications on different OSs on a single machine.

Docker isn’t the only containerization tool available on the market, nor was it the first. It did, however, simplified the process significantly, which immensely helped the technology gain a massive following in the tech world.

Pros and Cons of using Docker

Before we discuss the benefits of using Docker for WordPress, let’s talk about Docker’s main advantages and disadvantages.

Docker Pros:

  • Instant application deployment – you can create a separate container for every process and deploy an app within seconds. You can both create and destroy containers in an instant.
  • Modularity – you can “extract” any part of the application for an update or repair without having to take down the whole app. Docker allows you to break your app down into separate microservices, each containing its own function. These services are independent and can be easily isolated from each other.
  • Portability – you can pack the app and its dependencies into a single container and transfer it to another machine(s) with different hardware and OS setup without having to worry about compatibility issues.
  • Layering and image version control – Docker images are made of layers; a new layer is created whenever the image changes. The layers can be reused to produce new containers, significantly speeding up the process. Furthermore, all layer iterations are reflected in the built-in container changelog. This gives you complete control over Docker images and allows you to roll back any selected changes.
  • Sharing – you can simply share your containers with other developers using a remote repository.

Docker cons:

  • Data storage concerns – when a container shuts down, all of the data inside goes down as well. To save the data persistently in Docker, you need to employ certain solutions (e.g., Docker Data Volumes), but the process isn’t fully automated and can be challenging.
  • Not ideal for desktop apps with rich GUI – Docker works best when hosting applications running on the command console. It is possible, in theory, to run a graphical interface within a Docker container, but it’s unwieldy and inconvenient. Therefore, the most natural habitat for Docker containers would be web apps that run directly on a server.
  • Docker speeds up development, but not the app – the performance overhead of Docker isn’t significant, but it’s there, nevertheless. If the app’s speed is of primary concern, then using Docker may not always be the best idea.
You know
that you can change
your business.

Dockerize Your WordPress Site

Okay, now we know Docker’s main advantages and drawbacks. But what does it have to do with the WordPress site you plan to launch? The answer is – a local WordPress development environment.

Typically, if you want to run your WordPress website locally, you must set up a whole environment to support it. MySQL server, Apache, PhpMyAdmin, XAMPP – you name it. Furthermore, if you’re not big on wasting more time than needed, you’re stuck with your initial choices. For example, changing from Apache to NGINX can cause a small domino effect forcing you to reinstall other components. And let’s not forget the fact that swapping elements is the only way to go for testing different scenarios.

With Docker, you can forget all the inconveniences mentioned above. All you need to do is:

  • Install and run Docker
  • Download or create a Dockerfile with the required WordPress environment
  • Build WP Docker image
  • Launch the container

And that’s it! You can use the official WordPress Dockerfile and set your local WP environment up virtually within minutes, if not seconds. Once you’ve completed the setup, your WordPress site will be available locally at and ready for testing.

What’s great about Docker is that you can create multiple environments with different components and use them interchangeably. And when the time is right, you can push your dockerized WordPress to Staging and Production.

WordPress in Docker – our final thoughts

Using Docker isn’t the only way to set up a local development environment for WordPress, but it is, by far, the most convenient. Its modular nature allows for quick swapping of the components you want to test and utilize in your WP project. If you’re a part of a bigger team, you can easily share your containers with other devs, knowing your configuration will work as intended regardless of the machine it’s launched with.

At Develtio, we utilize Docker on a daily basis – we find it much more flexible than any other dedicated WordPress development environment solution. And thanks to its scalability, we are able to build environment templates for essentially every type of task we take on. If you’re wondering how your WordPress project can benefit from Docker, just drop us a line, and let’s talk containers!

What can we do for you?

Talk to us about your project and let's start building it together!

    This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

    Arkadiusz Zdziebko
    Head of Sales, Develtio