Set up WordPress with Docker… Fast!

Set up WordPress with Docker… Fast!

Welcome, Containerizers. So one of the
things I get a lot of questions about is how to set up WordPress in a Docker
environment. So what I’m going to do today is to show you the workflow that I’ve been
using for many months right now that works really well for me. So I’m going to add
our first service, being the database. So copy paste over here. So Docker Compose
file with one service for now, the data base from mysql:5.7. I’ll add a
name volume, as you can see underneath here, db_data, and I mount mysql folder to
that. So even when I remove the container, the data will still remain on my local
machine under the DB data name volume. I define the root password, not the safest
password, but just for my local environment for demo purposes right now.
And I create a network back for back ends to which I attach this database. I’m going
to launch this service now, opening a terminal. Docker-compose up -d,
demonized. So network is being created, the name volume is being created and the
mysql image is being pulled in and launched as a container. So docker ps
will show me one container running, that’s mysql, our database, cool. Now, to connect to the database,
I didn’t really publish to a port, so I cannot easily connect. What many
people prefer to do and for ease of use, I do the same, is use phpmyadmin.
So in our docker compose file, I’m going to add another service for
phpmyadmin. So copy-pasting that here, phpmyadmin, that exposes port 8080. Some
environment variables to connect to the database and also attaching
it to the back network. And docker-compose up -d, again. So now
phpmyadmin will be pulled in and run. And when I do docker ps, an extra
service is running phpmyadmin. So now when I go to the local host on port
8080, then I’ll see my phpmyadmin running over here. So root, and then with the
passwords that I put in my Compose file, and there we go. Now, for the most important service in our
installation, the WordPress service, of course. So I’m going to add a third
service in our docker-compose file. wordpress from image:wordpress and on
purpose, I’m going to use Image4.6, which is an older version. So we can
update it later on. And what I’m going to do, because I like to keep my
installations clean and just have the wp-content and not all the other
folders in the WordPress installation attached to my local machine. So I’m
doing a [inaudible 00:03:05] over here from the wp-content that contains the
themes and the plugins of my local machine to the container folder. Some environment variables to set
everything up, I publish on port 80 and 443 to open http and https connections
and I also connect this to the back end network. I forgot to save over here,
so I’m going to have to do that again. And now we’ll see that WordPress is
being run. Over here, probably didn’t see it, but in my folder, wp-content
was added. So when the container is starting up, the WordPress
container is starting up. It’s going to see is there already an
installation running. If not, it will do the full installation. So that’s what’s
happening over here. And then if we go to just local host, then I get the
installation screen for WordPress, which is nice. So let’s go on and do that.
Continue, wptest is my website, “test” username, “test” as password, very weak.
Confirming that, my email address, and and installing WordPress. And there we go,
done. So I’m going to log in to my freshly installed WordPress, log in and there we
go, my dashboard. So when I go to log in and there we go, my dashboard. So
when I go to the ‘about’ page, 4.6.2 is running. Now, as I said earlier, I’m
particularly interested to just have the wp-content folder attached to the code in
my local machine, so to prove that’s running, I’m going to the plugins, and,
yeah, by default, there’s always two plugins installed in the system.
Now, the plugin Hello_Dolly is one I won’t be using, so I’d like to keep things
clean, so removing that from my local file system. So when I go now in the
WordPress installation and refresh this page, we’ll see that the
Hello_Dolly plugin was removed. Another thing I’m not particularly fond of
in default WordPress installation is all the themes they install, so I’m also
going to delete those from the wp-content folder on my machine. I’m going to delete
all of those. And now assuming I have my own theme installed, so for demo purposes,
I’m just going to download one from the official site. So unpacking
that one and then when I open a Finder window over here, so this is my local
installation. I’m just going to drag and drop the new downloaded theme in this
now-empty folder. There we go. So, going back to my dashboard, when I’ll
refresh this, here’s my new theme. I’m going to activate that one.
Done. And when I visit my website, we have my fresh theme over here. As you
already probably have noticed, under my dashboard, there’s this red
button, red bullet over here that forced me to install or to upgrade to a new
WordPress version. So the first step I’m going to do is upgrade to
a newer WordPress image. So we were at 4.6, now I’m going
to switch over to 4.7.1. Save it, go into my terminal window and do what
docker-compose up demonized, just the WordPress container is going to
be recreated. So when I do a docker ps, we’ll see that my WordPress container is
running over here, version 4.7.1. But in the dashboards, you’ll still see
4.6.2. So the second step we’re going to need to do is do the actual upgrade
by clicking the “update now.” And there we go, upgrade finalized, we’re
on 4.7.1, no more red notifications over here. So that’s the way to go. So that concludes the presentation of my
WordPress workflow with Docker, let me know how you do your WordPress
workflows in the comments. And if you want to learn more about
containers, about Docker and the ecosystem surrounding it, just subscribe to this
channel, we’re pushing out more of these videos with demos and explanations.
Thank you for watching.

58 thoughts on “Set up WordPress with Docker… Fast!

  1. Being absolutely new to docker, after resisting it for so long…

    1. When updating the docker volume to 3.7.1 why did you have to click the update button within the admin ? Shouldn't that image contain the updated software?
    2. How would you deploy this to a live or staging server?
    3. How do you bind to local domains e.g. run this on locally – so that I can run multiple WordPress applications locally using a localized fqdn.

  2. Hi The Containerizers, I got problem:

    The localhost page isn’t working when I typed localhost:8000? I have used port 8000, please help me, thx

  3. Thanks for the video, but after I'm all up and running, I am unable to do things such as upload images, add plugins etc- without wordpress asking me for ftp credentials. I have looked around a bit, and tried chown-ing, but nothing seemed to work… I'm not afraid to use the command line if you know a way to get the permissions to work/ to avoid those issues.


  4. Great video!
    Question: Do you know how to make the development url to look like "" instead of "http://localhost"?

  5. Hi! Amazing video, you helped me a lot! I encountered a problem as I install a wordpress theme: "Mysql server has gone away". How can I change the timeout limit of my container? Thank you!

  6. Hi, nice video! 🙂
    One question, qhere is the php.ini file in order to increase the max_upload_file_size ? In some dockers I can create a file .ini under /usr/local/etc/php/conf.d

  7. Very helpful tutorial!

    What if I wanted to keep my mysql data on my host machine? What would I have to change?


    – ./data:/var/lib/mysql


    Is that correct?

  8. Great intro. Thanks for putting that together.

    What about multiple containers running at the same time? What about managing multiple development sites' urls in host/etc file.

  9. Hi again 🙂
    I trying to up the docker in the port 80, so when I enter my domain I get direct to wordpress site, but the if I put localhost it get always redirected to localhost:9000, I do not have any configuration for that, in the yml config for wordpress I putt 80:80.

    Any help is
    well welcomed 🙂

  10. I cannot get myPHPAdmin to sign in because it says "#1045 – Access denied for user 'root'@'' (using password: YES)"

    Here's my docker-compose:

    version: '2'
    – db
    image: wordpress:4.7.5-php5.6
    restart: always
    – ./wp-content:/var/www/html/wp-content
    WORDPRESS_DB_HOST: db:3306
    – 80:80
    – 443:443
    – back
    image: mariadb:10.3.0
    restart: always
    – db_data:/var/lib/mysql
    – back
    – db
    image: phpmyadmin/phpmyadmin
    restart: always
    – 8080:80
    PMA_HOST: db
    – back

    Any help will be greatly appreciated!

  11. A nice video, but it stops like most of web tutorials at the point where it becomes interesting: What about mail?? This video configuration is nice for learning Docker. And the video is very useful for this purpose. No question about that. But a fully fledged wordpress installation must of cource include the mail configuration. No thumb up, no thumb down.

  12. So i have WordPress running but I can't find that file you have it's strange but I did also download Docker tools if that makes any diff Thanks in advance

  13. Great video, but not super clear on the last couple lines `volumes: db_data` where is the data actually stored?

    Also, what would the setup look like for mail?

  14. Great video. And how would you recommend to do to have multiple instances on the same server pointing to differnet domains? (multiple wordpress website)

  15. so where is the benefit … fo dockerC. against debian/ubuntu/nginx server speed ? from customer perspektiv…i have running multi site on diff. server constellation.whats better ?? database access ? or general speed why ? if u wish u can send me email [email protected]…com …need to understand docker systems

  16. I am new to dockers.

    After searching lot of time in the time in Internet. I found your video.
    Thank you very much. Your video helped a lot.

  17. Newbie question. Using DockerToolbox for Win8.1 & Docker for Windows for Win10. But I use Win8.1 PC mostly.
    In this video,
    Did you create a local folder, e.g. c:/SomeFolder, and placed the yml file in that folder before you ran the command docker-compose up -d ?

    WRT Volume, does the subfolder, /var/lib/mysql, automatically created in this "c:/SomeFolder" directory automatically?

    I am in Windows environment, do I need to modified the yml file in order to ensure the "/var/lib/mysql" subfolder is created in the "c:/SomeFolder" directory?

    Will phpmyadmin also created in this "c:/SomeFolder" folder? i.e. I can still use phpmyadmin on my other mysql (non-docker) install in my PC?

    When I bring up docker, there is a localIP assigned: It is always the same IP whenever docker is up.
    In your video, when you tested WordPress, you used localhost.
    In my case, I can't use localhost to run WordPress but, correct?

    How did you configure your computer to run WordPress in localhost?

    Thanks in advance.

  18. Im having an autoptomize not enabled error when I launch wordpress.. Anybody ever experience this? I can SSH into my ec2 instance where my docker container is running and type docker exec -it <ImageID> chown -R www-data:www-data wp-content/, and this fixes it but im trying to do that directly from my docker file and not having any luck. Any Suggestions?

  19. with docker-compose up -d wordpress, my guess, is that you just updated the wordpress setup/installation, not the actual deployed software, isn't it? correct, if I'm wrong

  20. nice tutorial! one question are left.. how can i log with my sequal pro to this db container? it doesn't work for me with localhost or port 3306 with login root + pw

  21. Really helpful, thank you!

    I got this working, but now when I try to upload a plugin, I'm hitting a file size limit. I get the error "The uploaded file exceeds the upload_max_filesize directive in php.ini".

    Can you walk me through modifying this file? The container doesn't have vi, nor can I find php.ini! 🙁

    Thanks 🙂

  22. Thank you so much! your video is really helping me. I just have a question about WP updates.
    The manual update that you did after the image changes to 3.7.1 is only to update the version in the DB? or that's really downloading and updating the WP core codes?

  23. I created a docker-compose file following the demo code, but when I'm trying to install a WP plugin, it's showing me an error like this: "Installation failed: Could not create directory."
    I guess is something related by user permission, but I have no idea about how to fix it. (BTW, I'm using OSX)
    Do you have any idea about it?

    Thanks for your videos.

  24. This would be perfect for the office I support. One of our goal is that our people should know WordPress but installing it locally on every machine takes time just for them to test and learn. We want to have a local server that people can connect locally to and use WordPress for testing plugins and learning. This looks like it would be perfect for that. Are there any tutorial to set something like that up? To have multiple once running on a single server machine.

  25. I have an issue with permissions. I have added a volume to wordpress service '- ./wp-content:/var/www/html/wp-content' but from local environment I can't create files and folders and also change files

  26. Hi – this is a really great tutorial and I would love to try this method of yours but like so many other new users – what has got me stumped is where to locate these files? Please would you let us know where you created the folder that contains the wp-content? Also did you create a docker machine?

  27. Hey there. How do you get WP to send emails? Currently my docker WP setup is unable to send mail, and I don't seem to be able to find any good documentation on how to get it to work.

  28. Thankyou This helped a lot. I was unsure of the networks requirement but stuck with it then paired it back as it will use the default network created for that compose set. I was going wrong with the Database lines in the wordpress service. Thumbs up!!

  29. I'm having an issue with the plugins, the plugins that I installed in wp is missing on the other day that I open it. Whats the possible solution with this?

  30. Is there any way of using setting my own custom domain name instead of using localhost? I mean if I go into the docker container and edit the hosts file, it will just wipe the container info the next time I start it and I'd have to edit the hosts file every single time. Is there a way to setup a simple DNS server in the docker image?

  31. I followed your instructions but after I run `docker-composer up -d` and try to log in into PHPMyAdmin I get the:
    "mysqli_real_connect(): (HY000/1045): Access denied for user 'root'@'' (using password: YES)"

    I tried resetting the password but it still says access denied.

    Please help.

    I am dying.

  32. Nice video for be beginners. It looks like things have changed in last 3 years . Any one can answer

Leave a Reply

Your email address will not be published. Required fields are marked *