Video summary
This video provides a comprehensive guide on setting up a local WordPress development environment using Docker, specifically utilizing MariaDB for the database and phpMyAdmin for management. The presenter recommends installing Docker Desktop as it offers an intuitive interface and is free to use. To begin, viewers are instructed to create a project folder containing three essential files: a `.env` file for storing sensitive data like database credentials and container names, an `uploads.ini` file configured to increase the maximum upload size for large plugins or images, and a `docker-compose.yml` file that orchestrates the entire stack. The tutorial emphasizes copying these configurations from a provided template rather than writing them from scratch, ensuring efficiency while explaining how each component functions within the setup.
The core of the configuration lies in the `docker-compose.yml` file, which defines three distinct services: MariaDB, WordPress, and phpMyAdmin. Each service pulls official images from Docker Hub, allowing users to select specific versions if needed rather than being locked into a single release. The environment variables within this file link container names defined earlier in the `.env` file, ensuring unique identification for each component. Additionally, the setup includes permission adjustments on the WordPress directory to prevent common issues during plugin updates and utilizes the custom `uploads.ini` settings to handle larger files seamlessly. Once these files are prepared, users simply run a single command via their terminal or PowerShell—specifically `docker compose up -d`—to spin up all containers simultaneously in detached mode.
Upon successful execution of the start command, Docker Desktop displays running containers for each service with assigned ports; WordPress is accessible on port 8080 while phpMyAdmin runs on port 8081. By navigating to `localhost:8080` in a web browser, users can complete the standard WordPress installation wizard and immediately begin managing their site or updating plugins without affecting any live production data. The video also demonstrates how to access the database directly through phpMyAdmin at `localhost:8081`, where one can view tables under the default `wordpress` schema created by MariaDB. Furthermore, it explains that all persistent data is stored within Docker volumes located in a specific directory on the host machine's Linux subsystem, allowing users to manually inspect or modify files like themes and plugins if necessary before stopping the containers with `docker compose down --volumes`.
Read the full video transcript
Hey, welcome. In this video, I'm going
to show you how you can run WordPress
locally using Docker. And in order to
install WordPress, [music] we're going
to be using MariaDB as a database and
PHP MyAdmin to manage the database. In
this video, I'm going to be using Docker
Desktop. It does make things a lot nicer
and it's absolutely free to download.
So, go to the official website if you
wish to follow along and download it for
your machine and just make sure you
install it. The first thing that you
need is a project folder. So, I've
created one on my desktop here. I've
called mine folder wordpress-docker. So,
we'll need to create a free files in
order to create the Docker containers.
I've already got a blog post which is
going to be quite helpful to copy and
paste some of the files instead of
writing them and then I'm going to
explain what every file does. So, let's
open Visual Studio Code in this specific
folder. I'm going to do left shift right
click open the terminal.
And let's just open Visual Studio Code
or you can just open any editor just to
make it easier on us to create the
files. I'm going to open this. Let's go
to my blog. I'm going to link this in
the description below. It's basically
going to be a copy and paste job and you
can use this as a template. So, first of
all, we need to create a .env file. I'm
going to copy this.
Go to Visual Studio Code, create a new
file called .env.
Paste the data inside here and
essentially we need to have database
configuration. This is the name for the
database, the user and the password.
Because we're working locally, I don't
really care what the username is and the
password. I always just keep them as
root and password. Uh as they're not
exposed to the internet. Uh then for the
container names, they are important
because they need to be unique. So, in
this case, maybe I can just do
wordpress_docker.
And then DB. So, I'm going to copy this
and paste it twice like so. And
basically we have one for the database
container, one for the WordPress
container name, and one for the PHP
MyAdmin. After this, we have WordPress
configuration. This is going to be the
port number which we're running our
WordPress on. So, this would be
localhost with the port of 8080. And
then for the PHP MyAdmin, we're going to
be using 8081.
Save this and let's go back to my blog.
Now, let's add this uploads.ini file.
And this is essentially going to modify
the uploads max file size. So, if you're
uploading big plugins, that would be
quite nice for you. So, let's do a new
file.
uploads.ini
And then paste this.
Let's go to the last one here, which is
the docker-compose file
with the services. So, I'm going to copy
and create a new file. And this one is
going to be docker-compose.yml.
docker-compose.yml
Like so. And then let's paste the code.
Let's have a look through the code super
quickly and let's
Let me explain how it works. You don't
need to know absolutely everything and
you can always ask something like Lord
Gemini to help you out if you wish to
change some of the things. But
essentially, we have three services. The
first service is a database, the second
service is WordPress, and the last one
is PHP MyAdmin. If you look at those
services, we have an image container
name. So, the image itself, this is
going to be the image that you want to
install. So, in this case, I'm
installing MariaDB and I want to grab
the latest. Now, you might be wondering,
"Well, how do you know this?" Well, you
can check this if you go to the official
Docker container website. So,
hub.docker.com.
And then from here, you can actually
find the official images. So, as you can
see, we have Postgres here, Node, Ubuntu
and so on. So in this case, if we look
for let's say WordPress,
here is WordPress and if you click on
it, the beautiful thing about Docker is
that you can choose whatever image that
you wish. So if you need to have an
older version installed, you can grab
any of these versions and then just
replace them. So in this case, it would
be here. And the same goes for the Maria
DB and the same goes for the PHP My
Admin. So for Maria DB, for example,
you'd go here, search Maria DB
and let's say the official image is
here.
So you'll find the version that you want
and you'll give it a go.
That's pretty much it with images, but
as I said, I'm going to be using the
latest.
The container name, so every time you
see something with a dollar sign, this
is basically coming from the environment
variables. The container name is simply
uh here in the environment variables. So
if I search for it, it's the WordPress
Docker
uh Docker DB and the same goes for the
other ones. Uh if you have a look, we
have the root password, DB name, user,
password and so on.
Um these are the important things that
you need to know and then for the
WordPress itself, I think I've done a
couple of things. So basically, I'm
making everything uh in terms of
permissions, I've put this so you don't
get any problems with permissions like
when you update plugins and so on. And
then for the uploads, we've already done
this. So the uploads ini which will
allow us bigger file size to upload like
plugins, images, etc. That's more or
less it. And yeah, and now let's run
this and see how it works. So in order
to run this, you need to go back to the
PowerShell, command line, whatever
you're using. Make sure that you're in
your project folder and all you need to
do is docker
dash compose,
which is the file here, and then we need
to do up and then dash d. This should
take a second if you've already got the
images downloaded. If you this this your
first time doing it, it might take a
little bit longer than mine. Now, if we
go back to the docker desktop
application, you will see that we have
WordPress docker here, and it's already
running, which is great. If I open this,
you will see the docker website, the PHP
my admin, and the database. For the
docker site, we're running on 8080. For
the PHP my admin, we're running on 8081.
Essentially, we should be able to see
your website now in the browser. So,
let's do that. If you go to the browser
and let's do localhost of 8080,
and as you can see, we have a brand new
WordPress installed here. So, we just
need to set it up.
Let's confirm the weak password by
email, and let's set it up.
And here it is.
Password for the login.
And now you should be able to update
your plugins, uh install new ones, and
so on. Hey guys, sorry to pause the
video. I just wanted to share one of my
projects. AdSense [music] pays nothing
these days, and I've got no sponsor. So,
let me take 10 seconds to show you. Time
Track is a dead simple time tracker and
invoicing tool for small business owners
and freelancers, and I'll leave the link
in the description below. Uh now, back
to the video. We can test this by
updating the WordPress version super
quickly. So, let's update that. And if
it goes through, everything should be
good. Yep, it's all going through.
That's fine.
Update WordPress database. Continue.
Here we go. We have a plugin that we can
update is out. Uh the other thing that I
wanted to show you is the database now.
So, if you go to localhost of 8081 this
time, this is going to open the PHP my
admin, and I can log in again with root
and password.
And here it is. The database should be
under WordPress here. And here is the
actual database. And if you want to turn
off your project, basically delete your
containers, you can either go to the
desktop application and delete that
whole thing from here. Or you can go
back to the command line and do docker
dash compose
down and then dash dash volumes.
And this will delete every single
volume.
Here we go. So, that was going to be
everything, but I actually forgot to
show you where you can find your files.
So, let me uh do docker compose up again
one more time. So, the files, basically
when you install docker desktop, this
creates Linux subsystem for you. So, if
you go here on Windows, unfortunately, I
don't use Mac, so I won't be able to
tell you where it is, but you can always
always Google it. So, you need to find
your subsystem and then click on docker
desktop. From here, you need to go to
temp
docker desktop root var lib docker
volumes. And then you should be able to
find your volume here. And for example,
mine is this one here, WordPress docker
DB we have and we have WordPress docker
WP data, which is your WordPress data.
If we go inside, click on data, you
should be able to see your WordPress
website. And inside the WP content, of
course, you can add your plugins and
your themes if you wish to. And that's
pretty much it. If you like and found it
useful, consider liking it, subscribe to
my channel. [music] And if you have any
questions, please comment below.
>> [music]
[music]