Hey new viewers! If you would like to see more content on WordPress and Docker, let me know what ideas you have in mind or what you'd like to learn more about.
* How to use wp-env and configure on it composer autoload is the main problem. * How to make Vite compile with WordPress files and connect CI/CD dist for them. *Convert and connect fonts from otf and ttf to woff in WordPress project after compiling files on Vite. *Convert and connect img from jpg, png to webp in WordPress project after compiling files on Vite. *How to make a clear and clean structure for files in WordPress project for developing plugins and themes. *How to set up correctly and with best practices code style and lints for WP themes and plugin develop.
Thanks @aschmelyun its really helpful and really a good one and no doubt correct way to use docker with WordPress, waiting more videos on different topics please keep posting. Adding to this you can use wp-cli automation copying sh files to the root and execute installation and webpack internally setting apache/nginx logs can also be added to this.... thanks
This might be the best dev. tutuorial on the internet - the simplicity of the start that leads the viewer to an explanation of very complex solution while solving problems as they arrive is so gratifying to watch, combined with clear spoken Engish and being on point.
If you'd like to see the full code along with some additional helper items, check out the GitHub repo here: github.com/aschmelyun/docker-compose-wordpress
I like this plan a lot, but I'm wondering how deployable it is, since the certificates are bound to the NGINX container. Can you do a follow up on a deployment sequence?
After leaving previous job and not using my previous docker setup for months, I needed a refresher to get everything going on my personal laptop. Especially compared to all the various docs, SO threads, videos, and Reddit posts I went through when I created my prev job's new docker setup, this is the best Docker intro I've seen, nevermind best WP + Docker intro. You saved my bacon, dude. Will be checking out your other vids. Thanks for making this!
This was a nice refresher after spending the last couple of years away from WP and Docker. Half way through the video I was thinking "wp-cli would be so much easier, let me see how I can do that". And then I noticed you discussed it at the end. Doh! It's "Sea el eye" (CLI) and it stands for "Command Line Interface".
As a complete new comer to docker and launching WP containers, I found this video extremely useful as well as the comment threads where all my questions were answered already by previous helpful users. +1 Subscriber
Thank you very much Andrew! You can't imagine how much you've helped me understand how docker and docker -compose work. The configurations inside the containers is something I did not find anywhere else ... thank you so much for your generosity!
This is... so spot on and awesome. I love your delivery and explaining *everything* as you go along. Well done.
3 года назад
The thing I came here for, and got at the end of the video was how to keep plugin installations in version control. The answer seem to be to add a wp-cli container and put the commands to run in a dockerfile. Then, each time you start the service, it will run the wp-cli commands and install the plugins. Dunno exactly how or if that's persisted in the db, but I'm guessing it's just persisted in the wp-plugins directory and not in the database. Will give it a try on my own installation tomorrow. Thanks for a great, educational video. Keep em up, you earned yourself a subscriber!
I'm glad you found that part useful! As for persistence, the wp-cli container networks with the same db container that the main wp installation is using, so it should persist as long as you're using a volume on the MySQL container (or don't spin it down).
Thanks for the non-trivial approach (not just "image: wordpress"), in my opinion it is more flexible and interesting, since teaches some additional details regarding dockerization in general.
While WP will run fine , there are some missing modules , gd , imagick , bcmath, exif that can cause some issues with some plugins and themes . I would recommend a change to the php.dockerfile to include these , can be left out if you dont need them. RUN docker-php-ext-install mysqli pdo pdo_mysql bcmath exif && docker-php-ext-enable pdo_mysql bcmath exif RUN set -ex \ && apk add --no-cache --virtual .phpize-deps $PHPIZE_DEPS imagemagick-dev libtool \ && export CFLAGS="$PHP_CFLAGS" CPPFLAGS="$PHP_CPPFLAGS" LDFLAGS="$PHP_LDFLAGS" \ && pecl install imagick-3.4.3 \ && docker-php-ext-enable imagick \ && apk add --no-cache --virtual .imagick-runtime-deps imagemagick \ && apk del .phpize-deps RUN apk add --no-cache libpng libpng-dev && docker-php-ext-install gd && apk del libpng-dev of course if you add them , rebuild with docker-compose up -d --build site
Hello Andrew, I have just started getting into Docker and I was following along on this video when I ran into a snag. I got up to about the 9:50 mark, when I started the container that went fine, but when I tried refreshing the browser to start WordPress I am getting a 403 Forbidden error. I carefully looked over the code, and I am not seeing anything amiss. Hoping for some advice. Thank you
@@FranciscoSilva-rf3gw @Bruce Koehler, it is answered partially though. Add below line in the servers section of default.conf file, above locations index index.php;
Hi Andrew! Great video. I have one question. From your side, it's a good idea to run multiple WordPress project on the same docker env? For example, in the WordPress folder to have wp1 and wp2. Or should be separated? And another question. test1.local make a request to test2.local. Why I receive cURL error 6: Could not resolve host: test2.local? Thanks in advance.
Hmmm, seems promising, but after creating the nginx/default.conf file and specifying it in the docker-compose.yml file, nginx goes from the default Welcome to nginx page to just showing a generic 403 Access Forbidden page.
Check if you miss any semicolons in your config file. Also you can run "docker logs -f " followed by the containername of your nginx and see what the error is 😊
Press F12 on the browser and go to the network section, look for a title called ‘GET’ which is the get request to load the page. See if you can expand that title and find more info of the file it’s trying to access. It might very well be a permissions issue on Linux. I encountered this when I tried doing a docker project in the home/user folder.try create the project in your root directory
Amazing Tutorial. I have been using compose-file from others because I always ran into one problem or other. But because of your approach of letting things fail and fixing it, I not only ran wordpress, but also successfully ran laravel setup. Now I will try my hand on Laravel-Vue microservice setup because that is what my actual app is using. I am guessing I just need to create another service called node and try to match ports between them just like you did on fpm?
It's a splendid tutorial. Thank you. Just one quibble: at around 11:00, where you say, oh, this is crashing because the PHP mysql extension is missing -- there is no way anybody could infer that from the opaque error message that Wordpress displays. It would be nice to know where the error logs are and see for ourselves.
For anyone having the error establishing database connection. Make sure you set up your database connection in the wp-config.php file, you will initially see there a wp-config-sample.php file. This tutorial skipped it. Nevertheless, good tutorial! Thanks!
9:56 please help How to get wp-config.php file without copy and paste inside wordpress.. Bcz after that plugin and media Don't word.. After all this is best learning methodology...
I downloaded your code and after reviewing the video I customized it for my needs. I can start the nginx, mysql and php but I can see in the Docker Desktop that wp cannot be started, or it stops immediately with this error: "less: unrecognized option: r". Do you have an idea what can cause this? Thanks in advance!
Andrew - for info the line try_files $uri $uri / /index.php?$args; yields a 403 forbidden until you remove the second $uri/ - This is caused because nginx will try to index the directory, and be blocked by itself. Throwing the error. try_files $uri $uri/ means, from the root directory, try the file pointed by the uri, if that does not exists, try a directory instead (hence the /). When nginx access a directory, it tries to index it and return the list of files inside it to the browser/client, however by default directory indexing is disabled, and so it returns the error "Nginx 403 error: directory index of [folder] is forbidden". see nginx.org/en/docs/http/ngx_http_autoindex_module.html
No problem , and excellent video in any case , really helped me to understand docker setup , I especially liked you showing what can go wrong and how to fix them ! keep it up
Hi Andrew, thank you for the great video! Unfortunately there is a problem, after I added an /nginx folder to store default.conf and make docker-compose up -d again, what I see is not WP's installation page but '403 Forbidden' page by nginx, could you tell me what happen? I use WSL on Windows 11. Thanks!
I just watched your video and I have to say I found it really interesting. Recently, I've been trying to do exactly the same thing but with the setup of a Real Cronjob. Could you give me some advice on this? How do you configure a Real Cronjob in Docker that works with WordPress? Thank you so much in advance!
thanks for the great tutorial. I am following along, checked 100 times, and maybe there has been some changes with docker. 01. When I try to perform the setup I get the error "Error establishing a database connection". I used everything as you have it. Is there a solution that you may recommend, please? 02. It seems that it redirected automatically from "localhost" to "wordpress-docker.test", it doesn't do this automatically for me. Was there something that you did in between?
If one uses multiple servers, where one has db, other has cache and two others have the webapp itself, would it be smart to have docker only for development, and use some other way to handle the production servers? Or is there a good established way to do this with docker too, where development and deployment have each their own setup? And how would one run only one part of the app on one server? Kubernetes might solve the issue, but seems like an overkill for this problem.
When running the docker through a WSL distro(ubuntu in my case), does the second path you specify in the volumes section in 25.15 exist virtually or should the folder exist on the local machine through manual installation(sudo apt insall nginx) of nginx outside the docker environment? I don't understand how the symlinks work. I'm guessing that the /var/www/html folder doesn't actually exist physically on your device either.
This tutorial absolutely rocks. I followed the tutorial and used the same example URL, but now that I want to change it I can't (even though I changed it in the default.conf). Any tips how to fix it?
Perhaps I'm missing something, but why is WordPress manually brought in like that (downloaded and just added)? Can't it be brought in and version controlled/updated in the same way that the other services were, in a composer-like way? I thought that was the whole point of all of this.
While WordPress doesn't officially have a composer entry, it is installable through it with 3rd-party forks. However, the point of this video was to demonstrate how to get a local environment up for a new or existing WP site using Docker and separate containers for each process. There could be some more streamlining done with this, and I'll take that into consideration when thinking of follow-up videos on this topic!
I am having problems with permissions. It would appear as if the container uses a user called "82 [82]". It is breaking a lot of things in WordPress like media and plugins, along with updates. If anyone has the time to help please give it. I don't know how to share permissions with a user that is in a docker container.
Clear and concise! Would like to know how you added the custom domain name? Is there a way to have that done automatically similar to laravel valet where the directory name is taken as the domain name?
Edit your hosts file and add line 127.0.0.1 wordpress-docker.test ( on windows this is in C:/windows/system32/drivers/etc - but edit as administrator !)
Hi Andrew! I mounted a server without nginx on dockers. I started toying around and dind't follow a guide to make this server https compatible before changing this on the wordpress settings. I ended up wrecking my whole docker instance. I ended up erasing also the DB associated with Wordpress. I tried closing down the docker instance and composing up again, but to no good. Is there a 'hard-reset' to start all over again? Appreciate your help :)
Hi Andrew, great video. this is for localhost what changes do i have to add to deploy this on app service or ACI in Azure? many thank for the reply! have a great day..
Excellent video again. Would be nice if you would make a video on implementing xdebug. Currently struggling to get that working with docker, php and vscode.
could Add following to php.dockerfile RUN apk add --no-cache --virtual .build-deps $PHPIZE_DEPS \ && pecl install xdebug \ && docker-php-ext-enable xdebug \ && apk del -f .build-deps needs additional config to setup new mode and ide key etc for new xdebug 3 works as far as loading xdebug in php , but have not figured out the additional configs yet to get it to work on VSCODE , next task !
Great tutorial! Unfortunately my Wordpress installation is slow, takes -+7 seconds to load a single page. I'm running Windows 10 and Docker on a SSD, so it should not be so slow. Is there any way I can improve speed?
I have the same issue, did some research and WSL2 seems to be the issue, if you have windows on its pro version you can disable it in docker dashboard > settings > General > Use WSL2 based engine
@@jorgearaya4712 hyper-v isn't just faster on Windows, it also uses only 2GB of ram instead of WSL2 which uses 4+ GB when running the wordpress container.
In the wpcli.dockerfile add a RUN command "RUN apt update && apt install mysql-client". If you don't you can not use wpcli, it will complain about mysql not being found.
Sorry if this was answered before, but since I'm using windows and I DON'T want to use HyperV for Docker (I'm using VirtualBox for other things), and that I can't really use WSL2 at the moment (can't afford a restart, too many things running LOL), do you think it is recommended that I spin up a debian-testing vm, install docker engine in there, and then through VSCode's Remote Dev extension I develop things with docker in that vm? I mean, yea, I can just dual-boot, but I think I'm too swamped with work atm to reorganize my stuff. Sorry if this was a dumb question.
Not a dumb question at all! That definitely sounds like a complicated setup, and I think the solution you laid out sounds pretty good for your scenario. Especially if you're just doing local dev, your VM shouldn't need that much resource allotment for the Docker instance.
@@aschmelyun Thanks for the reply, I'm slowly transferring my dev environments over to docker, since VM with snapshots are taking a tad bit too much space for my liking. My current environment is more like anything I've not handed off yet or that I need to maintain, I'm sticking with what I had. But any new projects coming my way or things I need to do for the team I'm in, I put them in docker. No doubt my projects are slowly cleaning up, and it's.. a chore, to put it kindly, to reorganize things when everything is being worked on.
At 8:17 I got the error "Error response from daemon: invalid mount config for type "bind": bind source path does not exist: /run/desktop/mnt/host/e/wordpress-docker-test/wordpress" Working in Docker for Windows (WSL) so that might be why I'm having such a hard time with this stuff...
After running the docker-compose up command, I just navigated to localhost. In this case, I set an entry in my /etc/hosts file to 127.0.0.1 wordpress-docker.test to get a fake URL in my browser.
if you're on windows & having troubles following the tutorial after 8:00 You might need to update File Sharing configuration in your Docker for Windows app to include your work directory :"D
Nice tutorial! One thing popped into my mind: before firing up the development environment, Wordpress needs to be downloaded into local machine and extracted into /wordpress directory. This is makes sense if you're developing existing project: just drop it into /wordpress directory and continue developing it. However, it would be handy if you didn't have wordpress already in /wordpress directory, it would be downloaded automatically when the containers are started. This would allow to use this as a handy way of starting a new Wordpress project. I know it's not big of a deal to go get Wordpress and extract it, but automatic is always automatic! :D How complicated would adding this sort of functionality be?
You could be doing that but consider that the fact that manually adding code is a one-time only process. So it makes sense not to add logic into the startup to fulfill this need. You'd basically need a script in the entrypoint that: - Checks if there's a /wordpress directory. If there isn't: - Downloads the latest version - Installs an unzip tool in the container (further adding dependencies that we don't want in a docker container) - Unzips Then if you've mapped the volume correctly, from outside of the container to the local folder, you should see the wordpress files there. I mean that could work if you're really doing multiple wordpress sites. But for a one off, I don't think it is worth the hassle. Even if you're running a big marketing agency, you'll probably have the boilerplate repository with everything to go. This also gives you the capability to manually decide when you want to use a new wordpress version. Specially if there's major/breaking changes involved compared to the old one you were using.
I have a permission error. Someone went through this. "It was not possible to write data to the wp-config.php file. You can create wp-config.php file manually and paste the following text into it." how to solve this? I even created the wp-config manually, but do not install any plugins. Thanks
What Colman said is a good workaround. If you check out the pinned GitHub there's a fix for this in the php.dockerfile that handles chown of the volume's files.
@@aschmelyun Do you mean RUN chown wp:wp /var/www/html ? If so, then unfortunately after I've installed wp with wp cli and ran --build site - I still can't change the wp-content folder and all files in it :( plz help
Hi Andrew, thanks for the tutorial. i was trying it out but can't seem to get the wp container to start. The log says less: unrecognized option: r I can still install wordpress and access the dashboard on localhost but the container is grayed out. Please advise. Thanks again for the great tutorials!
Hey new viewers! If you would like to see more content on WordPress and Docker, let me know what ideas you have in mind or what you'd like to learn more about.
* How to use wp-env and configure on it composer autoload is the main problem.
* How to make Vite compile with WordPress files and connect CI/CD dist for them.
*Convert and connect fonts from otf and ttf to woff in WordPress project after compiling files on Vite.
*Convert and connect img from jpg, png to webp in WordPress project after compiling files on Vite.
*How to make a clear and clean structure for files in WordPress project for developing plugins and themes.
*How to set up correctly and with best practices code style and lints for WP themes and plugin develop.
@@karlson2804 great suggestion✌
Thanks @aschmelyun its really helpful and really a good one and no doubt correct way to use docker with WordPress, waiting more videos on different topics please keep posting.
Adding to this you can use wp-cli automation copying sh files to the root and execute installation and webpack internally setting apache/nginx logs can also be added to this.... thanks
Wordpress theme development with Bedrock and Sage
Was hoping to see phpmyadmin installed as well on this tutorial. It is Great tutorial, thank you!
I really appreciate how you let stuff break, and then went back and showed how to fix those things!! I thought that was really helpful! Thank you!!!
Thanks for noticing! It's how I learn best, so I figured it's the better way to show it!
oh yeah this is amazingly detail. I love it! Thank you
This might be the best dev. tutuorial on the internet - the simplicity of the start that leads the viewer to an explanation of very complex solution while solving problems as they arrive is so gratifying to watch, combined with clear spoken Engish and being on point.
Seriously this is the most clean, clear and on point example. Very underrated.
This is the best tutorial that I found about wordpress docker. Thank you for this tutorial, I will continue watching you other videos.
This is how a tutorial video should be made. Kudos and many many thanks to Andrew.
I'm glad you liked it, thanks so much!
If you'd like to see the full code along with some additional helper items, check out the GitHub repo here: github.com/aschmelyun/docker-compose-wordpress
@andrew schmelyun Have you tried adding xdebug with this and making it work. It's too complicated to set up.
I like this plan a lot, but I'm wondering how deployable it is, since the certificates are bound to the NGINX container. Can you do a follow up on a deployment sequence?
@@PeterMumford Sure thing! I'll add it to my list.
When i try to clone this repo it don’t work well. As well as you can make another vedio in this particular issue.
Your git repo lots of extra code bit you skip this please you can make full tutorial i hope it will help people who learn More
After leaving previous job and not using my previous docker setup for months, I needed a refresher to get everything going on my personal laptop. Especially compared to all the various docs, SO threads, videos, and Reddit posts I went through when I created my prev job's new docker setup, this is the best Docker intro I've seen, nevermind best WP + Docker intro. You saved my bacon, dude. Will be checking out your other vids. Thanks for making this!
Took me some back and forth but I eventually got it working after watching your video. Thanks for the great tutorial!!!
Andrew, this was a great tutorial. Keep up the good work, appreciate you putting in the time for this.
You've got a new subscriber in me. Loving the Laravel + Docker tutorials. Cheers
I rarely comment on a video, but u just earned a new subscriber, very good content
This was a nice refresher after spending the last couple of years away from WP and Docker. Half way through the video I was thinking "wp-cli would be so much easier, let me see how I can do that". And then I noticed you discussed it at the end. Doh! It's "Sea el eye" (CLI) and it stands for "Command Line Interface".
As a complete new comer to docker and launching WP containers, I found this video extremely useful as well as the comment threads where all my questions were answered already by previous helpful users. +1 Subscriber
Thank you very much Andrew! You can't imagine how much you've helped me understand how docker and docker -compose work. The configurations inside the containers is something I did not find anywhere else ... thank you so much for your generosity!
Excellent Docker tutorial :) Would love to see a similar guide on how to set up up a Test-Driven Development (PHPUnit) for WordPress using Docker!
I'll add it to the list!
Yes, this would be great!
This is... so spot on and awesome. I love your delivery and explaining *everything* as you go along. Well done.
The thing I came here for, and got at the end of the video was how to keep plugin installations in version control.
The answer seem to be to add a wp-cli container and put the commands to run in a dockerfile. Then, each time you start the service, it will run the wp-cli commands and install the plugins.
Dunno exactly how or if that's persisted in the db, but I'm guessing it's just persisted in the wp-plugins directory and not in the database.
Will give it a try on my own installation tomorrow. Thanks for a great, educational video.
Keep em up, you earned yourself a subscriber!
I'm glad you found that part useful! As for persistence, the wp-cli container networks with the same db container that the main wp installation is using, so it should persist as long as you're using a volume on the MySQL container (or don't spin it down).
Thanks for the non-trivial approach (not just "image: wordpress"), in my opinion it is more flexible and interesting, since teaches some additional details regarding dockerization in general.
While WP will run fine , there are some missing modules , gd , imagick , bcmath, exif that can cause some issues with some plugins and themes .
I would recommend a change to the php.dockerfile to include these , can be left out if you dont need them.
RUN docker-php-ext-install mysqli pdo pdo_mysql bcmath exif && docker-php-ext-enable pdo_mysql bcmath exif
RUN set -ex \
&& apk add --no-cache --virtual .phpize-deps $PHPIZE_DEPS imagemagick-dev libtool \
&& export CFLAGS="$PHP_CFLAGS" CPPFLAGS="$PHP_CPPFLAGS" LDFLAGS="$PHP_LDFLAGS" \
&& pecl install imagick-3.4.3 \
&& docker-php-ext-enable imagick \
&& apk add --no-cache --virtual .imagick-runtime-deps imagemagick \
&& apk del .phpize-deps
RUN apk add --no-cache libpng libpng-dev && docker-php-ext-install gd && apk del libpng-dev
of course if you add them , rebuild with docker-compose up -d --build site
After follow YOUR code i cannot compose file getting error.. Can you help
thanks for this awesome tutorial. really helped me to set up a local development environment without resorting to MAMP or something similar
This video is so well designed! Thank you so much for the time and effort you have put into this informative video!
Hello Andrew, I have just started getting into Docker and I was following along on this video when I ran into a snag. I got up to about the 9:50 mark, when I started the container that went fine, but when I tried refreshing the browser to start WordPress I am getting a 403 Forbidden error. I carefully looked over the code, and I am not seeing anything amiss. Hoping for some advice. Thank you
Hello Bruce, i have the same error, did you manage to solve it?
@@FranciscoSilva-rf3gw @Bruce Koehler, it is answered partially though. Add below line in the servers section of default.conf file, above locations
index index.php;
This is awesome. Its the best docker-php tutorial yet.
Amazing video Andrew ! Thanks for sharing
Hi Andrew! Great video. I have one question. From your side, it's a good idea to run multiple WordPress project on the same docker env? For example, in the WordPress folder to have wp1 and wp2. Or should be separated?
And another question. test1.local make a request to test2.local. Why I receive cURL error 6: Could not resolve host: test2.local?
Thanks in advance.
Best wordpress-docker set-up video.
Every step was clear and clean, very well explained. thanks a lot.
Hmmm, seems promising, but after creating the nginx/default.conf file and specifying it in the docker-compose.yml file, nginx goes from the default Welcome to nginx page to just showing a generic 403 Access Forbidden page.
same
got any solution?
same, its weird
Check if you miss any semicolons in your config file.
Also you can run "docker logs -f " followed by the containername of your nginx and see what the error is 😊
Press F12 on the browser and go to the network section, look for a title called ‘GET’ which is the get request to load the page. See if you can expand that title and find more info of the file it’s trying to access. It might very well be a permissions issue on Linux. I encountered this when I tried doing a docker project in the home/user folder.try create the project in your root directory
followed you youtube tutorial but can get to nginX but cannot get to wordpress.. something about missing mysqli???
Amazing Tutorial. I have been using compose-file from others because I always ran into one problem or other. But because of your approach of letting things fail and fixing it, I not only ran wordpress, but also successfully ran laravel setup. Now I will try my hand on Laravel-Vue microservice setup because that is what my actual app is using. I am guessing I just need to create another service called node and try to match ports between them just like you did on fpm?
Really clear and easy to follow tutorial, many thanks. subscribed!
It's a splendid tutorial. Thank you. Just one quibble: at around 11:00, where you say, oh, this is crashing because the PHP mysql extension is missing -- there is no way anybody could infer that from the opaque error message that Wordpress displays. It would be nice to know where the error logs are and see for ourselves.
For anyone having the error establishing database connection. Make sure you set up your database connection in the wp-config.php file, you will initially see there a wp-config-sample.php file. This tutorial skipped it. Nevertheless, good tutorial! Thanks!
This is true, and I apologize for that! DB host should be pointing to `mysql`, not the typical localhost.
9:56 please help How to get wp-config.php file without copy and paste inside wordpress.. Bcz after that plugin and media Don't word.. After all this is best learning methodology...
up because I got stuck there too, makes sense thanks
By default it was not generated.. Thats problem occur.. How to solve u don’t say that
You are the best tutor. Thanks from Indonesia.
Great video! This is exactly what I was looking for. Can you show how to push this to a VPS for production?
I'll add it to my video ideas list!
amazing guide! every step is well explained and doesn't left any confusion, thank you!
Bookmarked this. Everything covered nicely. 👍
Nice! Your explanation is so helpful, cool and clear! Thanks... I needed this
Thank you so much! I'm glad it was helpful.
I downloaded your code and after reviewing the video I customized it for my needs. I can start the nginx, mysql and php but I can see in the Docker Desktop that wp cannot be started, or it stops immediately with this error: "less: unrecognized option: r". Do you have an idea what can cause this? Thanks in advance!
Excellent video. Could not be better explained. Thanks for sharing this.
Andrew - for info the line try_files $uri $uri / /index.php?$args; yields a 403 forbidden until you remove the second $uri/ - This is caused because nginx will try to index the directory, and be blocked by itself. Throwing the error.
try_files $uri $uri/ means, from the root directory, try the file pointed by the uri, if that does not exists, try a directory instead (hence the /). When nginx access a directory, it tries to index it and return the list of files inside it to the browser/client, however by default directory indexing is disabled, and so it returns the error "Nginx 403 error: directory index of [folder] is forbidden". see nginx.org/en/docs/http/ngx_http_autoindex_module.html
add line
index index.php;
with that, nginx will search for index files inside /var/www/html
@@heliocorreia1359 This is correct. That line was missing from the original video, but is present in the code on GitHub. My apologies!
No problem , and excellent video in any case , really helped me to understand docker setup , I especially liked you showing what can go wrong and how to fix them ! keep it up
@@heliocorreia1359 that didn't work. I'm still getting 403
Hi Andrew, thank you for the great video!
Unfortunately there is a problem, after I added an /nginx folder to store default.conf and make docker-compose up -d again, what I see is not WP's installation page but '403 Forbidden' page by nginx, could you tell me what happen? I use WSL on Windows 11. Thanks!
same problem lmao, this tutorial is 10 months ago so probably the latest update is fucking us up
have you fixed it?
in the nginx/default.conf file you need to add this index line in the server configuration:
root /var/www/html;
index index.php;
@@spouwn Thanks. This helped me today 😅
@@spouwn thank you so much :)
I just watched your video and I have to say I found it really interesting. Recently, I've been trying to do exactly the same thing but with the setup of a Real Cronjob. Could you give me some advice on this? How do you configure a Real Cronjob in Docker that works with WordPress? Thank you so much in advance!
Hi i follow your step but it's not working. show "403 Forbidden". my os is Ubuntu 20.04
Such an excellent channel, really appreciate the time you've dedicated to helping us learn new things!
Thank you!
Wonderful content!
Please help us setting the Roots Stack Environment on Docker too! (Bedrock, Sage...)
You got it! I'll add that to my list.
@@aschmelyun hehehe, thanks bro!
this the most well explained video regarding docker. Thank you
what a quality step by step explanation!
Docker + Bedrock + Sage = Paradise
thanks for the great tutorial. I am following along, checked 100 times, and maybe there has been some changes with docker.
01. When I try to perform the setup I get the error "Error establishing a database connection". I used everything as you have it.
Is there a solution that you may recommend, please?
02. It seems that it redirected automatically from "localhost" to "wordpress-docker.test", it doesn't do this automatically for me. Was there something that you did in between?
very helpfull, explained very well how everything works. thanks
Awesome!! Thank you for this video!
If one uses multiple servers, where one has db, other has cache and two others have the webapp itself, would it be smart to have docker only for development, and use some other way to handle the production servers? Or is there a good established way to do this with docker too, where development and deployment have each their own setup? And how would one run only one part of the app on one server?
Kubernetes might solve the issue, but seems like an overkill for this problem.
When running the docker through a WSL distro(ubuntu in my case), does the second path you specify in the volumes section in 25.15 exist virtually or should the folder exist on the local machine through manual installation(sudo apt insall nginx) of nginx outside the docker environment? I don't understand how the symlinks work. I'm guessing that the /var/www/html folder doesn't actually exist physically on your device either.
This tutorial absolutely rocks. I followed the tutorial and used the same example URL, but now that I want to change it I can't (even though I changed it in the default.conf). Any tips how to fix it?
Perhaps I'm missing something, but why is WordPress manually brought in like that (downloaded and just added)? Can't it be brought in and version controlled/updated in the same way that the other services were, in a composer-like way? I thought that was the whole point of all of this.
While WordPress doesn't officially have a composer entry, it is installable through it with 3rd-party forks. However, the point of this video was to demonstrate how to get a local environment up for a new or existing WP site using Docker and separate containers for each process.
There could be some more streamlining done with this, and I'll take that into consideration when thinking of follow-up videos on this topic!
@@aschmelyun Cool, thanks for taking the time to reply. Looking forward to follow-up content. Cheers!
That video helped me a lot, thanks, man!
An excellent and informative lesson, Thank you so much.
This is how tutorial should be made. i wish i could like more.
I keep getting an error
[error] 128#128: *31 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream,
I am having problems with permissions. It would appear as if the container uses a user called "82 [82]". It is breaking a lot of things in WordPress like media and plugins, along with updates. If anyone has the time to help please give it. I don't know how to share permissions with a user that is in a docker container.
I get an issue with adding a post(API JSON error) as well as when updating plugins and worpress as well as themes - FTP details are requested.
great job but why use this instead of xampp, wamp, local or laragon?
Clear and concise! Would like to know how you added the custom domain name? Is there a way to have that done automatically similar to laravel valet where the directory name is taken as the domain name?
Edit your hosts file and add line 127.0.0.1 wordpress-docker.test ( on windows this is in C:/windows/system32/drivers/etc - but edit as administrator !)
@@ColmanByrne Thanks! For anyone else doing this just add it below the # comments when editting the hosts.file in visual studio code
Hi Andrew!
I mounted a server without nginx on dockers. I started toying around and dind't follow a guide to make this server https compatible before changing this on the wordpress settings.
I ended up wrecking my whole docker instance. I ended up erasing also the DB associated with Wordpress. I tried closing down the docker instance and composing up again, but to no good.
Is there a 'hard-reset' to start all over again?
Appreciate your help :)
Hi! Thanks a lot for your content! Could you leave links to src file in descriptions, pls.
What about deployment on the server :3 I am searching for it now
do you have single Dockerfile with alpine base image installed with wordpress,php,nginx?
Excellent WordPress guide!
Thank you! I’m glad you liked it.
Hi Andrew, great video. this is for localhost what changes do i have to add to deploy this on app service or ACI in Azure? many thank for the reply! have a great day..
Awesome! How we can create multiple WordPress sites on local this way?
Excellent video again.
Would be nice if you would make a video on implementing xdebug. Currently struggling to get that working with docker, php and vscode.
Great idea! I love xdebug, I'll be sure to add that to my video list.
could Add following to php.dockerfile
RUN apk add --no-cache --virtual .build-deps $PHPIZE_DEPS \
&& pecl install xdebug \
&& docker-php-ext-enable xdebug \
&& apk del -f .build-deps
needs additional config to setup new mode and ide key etc for new xdebug 3 works as far as loading xdebug in php , but have not figured out the additional configs yet to get it to work on VSCODE , next task !
@@ColmanByrneI have XDEBUG already up and running, but thank you anyway for your response.
Great starter tutorial.
I have trouble uploading larger files, either media or plugins. Any help here?
Great, thanks a lot. The only think I'm not getting right is the certs. Chrome says it's not good. Cheers.
hi guys, does anyone know how can I fix the add plugins page. I am unable to download and install plugins. This is also the same in cli command. TIA
Great video! Thx for helpful information
Hi Thank you for the video, very helpful. What is entrypoint: ['wp', '--allow-root'] for?
Great tutorial!
Unfortunately my Wordpress installation is slow, takes -+7 seconds to load a single page. I'm running Windows 10 and Docker on a SSD, so it should not be so slow. Is there any way I can improve speed?
Hi, did you solve it?
I have the same issue, did some research and WSL2 seems to be the issue, if you have windows on its pro version you can disable it in docker dashboard > settings > General > Use WSL2 based engine
@@jorgearaya4712 hyper-v isn't just faster on Windows, it also uses only 2GB of ram instead of WSL2 which uses 4+ GB when running the wordpress container.
With a few tweaks it worked thanks 🙂
In the wpcli.dockerfile add a RUN command "RUN apt update && apt install mysql-client". If you don't you can not use wpcli, it will complain about mysql not being found.
Excellent walkthrough
my web browser Edge gives me the 403 error forbidden. how do i resolve this ?
thanks, Andrew! I learn a lot!
Sorry if this was answered before, but since I'm using windows and I DON'T want to use HyperV for Docker (I'm using VirtualBox for other things), and that I can't really use WSL2 at the moment (can't afford a restart, too many things running LOL), do you think it is recommended that I spin up a debian-testing vm, install docker engine in there, and then through VSCode's Remote Dev extension I develop things with docker in that vm?
I mean, yea, I can just dual-boot, but I think I'm too swamped with work atm to reorganize my stuff. Sorry if this was a dumb question.
Not a dumb question at all! That definitely sounds like a complicated setup, and I think the solution you laid out sounds pretty good for your scenario. Especially if you're just doing local dev, your VM shouldn't need that much resource allotment for the Docker instance.
@@aschmelyun Thanks for the reply, I'm slowly transferring my dev environments over to docker, since VM with snapshots are taking a tad bit too much space for my liking.
My current environment is more like anything I've not handed off yet or that I need to maintain, I'm sticking with what I had. But any new projects coming my way or things I need to do for the team I'm in, I put them in docker. No doubt my projects are slowly cleaning up, and it's.. a chore, to put it kindly, to reorganize things when everything is being worked on.
At 8:17 I got the error "Error response from daemon: invalid mount config for type "bind": bind source path does not exist: /run/desktop/mnt/host/e/wordpress-docker-test/wordpress"
Working in Docker for Windows (WSL) so that might be why I'm having such a hard time with this stuff...
Is possible to use Dbeaver for this enviroment? thank you in advance
Wow, amazing tutorial!
What should be done if multiple wordpress sites needs to configure like virtualhost?
9:52 >> how did you get that wordpress installation page
After running the docker-compose up command, I just navigated to localhost. In this case, I set an entry in my /etc/hosts file to 127.0.0.1 wordpress-docker.test to get a fake URL in my browser.
@@aschmelyun yeah I heard that in the video but can you please share the steps to do that. Thank you
@@MajesticRiderTales He just told you. Add an entry in your /etc/hosts file so that wordpress-docker.test points to localhost (127.0.0.1).
if you're on windows & having troubles following the tutorial after 8:00
You might need to update File Sharing configuration in your Docker for Windows app to include your work directory :"D
Great tutorial, thanks.
If one would like to use this with apache server, how would default.conf file Look like for apache?
Thank you
Nice tutorial! One thing popped into my mind: before firing up the development environment, Wordpress needs to be downloaded into local machine and extracted into /wordpress directory. This is makes sense if you're developing existing project: just drop it into /wordpress directory and continue developing it. However, it would be handy if you didn't have wordpress already in /wordpress directory, it would be downloaded automatically when the containers are started. This would allow to use this as a handy way of starting a new Wordpress project. I know it's not big of a deal to go get Wordpress and extract it, but automatic is always automatic! :D How complicated would adding this sort of functionality be?
I hit the same issue. I expected that something needs to go into the *./wordpress* directory, but I don't believe that it's mentioned in the video.
You could be doing that but consider that the fact that manually adding code is a one-time only process. So it makes sense not to add logic into the startup to fulfill this need. You'd basically need a script in the entrypoint that:
- Checks if there's a /wordpress directory. If there isn't:
- Downloads the latest version
- Installs an unzip tool in the container (further adding dependencies that we don't want in a docker container)
- Unzips
Then if you've mapped the volume correctly, from outside of the container to the local folder, you should see the wordpress files there.
I mean that could work if you're really doing multiple wordpress sites. But for a one off, I don't think it is worth the hassle. Even if you're running a big marketing agency, you'll probably have the boilerplate repository with everything to go. This also gives you the capability to manually decide when you want to use a new wordpress version. Specially if there's major/breaking changes involved compared to the old one you were using.
I have a permission error. Someone went through this.
"It was not possible to write data to the wp-config.php file.
You can create wp-config.php file manually and paste the following text into it."
how to solve this? I even created the wp-config manually, but do not install any plugins. Thanks
chmod -R 777 the wordpress folder
What Colman said is a good workaround. If you check out the pinned GitHub there's a fix for this in the php.dockerfile that handles chown of the volume's files.
@@aschmelyun
add wp as the user with uid 1000 didn't work for me. What am I missing?
@@aschmelyun Do you mean RUN chown wp:wp /var/www/html ? If so, then unfortunately after I've installed wp with wp cli and ran --build site - I still can't change the wp-content folder and all files in it :( plz help
Nice video, please how do you set domain kind .test?... can you share how do you do that please?.. Thank you.
Super video, thanks!
I followed every steps, but can't get the same results at 13:30, i get a database connection error :'(
Hi Andrew, thanks for the tutorial. i was trying it out but can't seem to get the wp container to start. The log says
less: unrecognized option: r
I can still install wordpress and access the dashboard on localhost but the container is grayed out. Please advise. Thanks again for the great tutorials!
Add following line to your php.dockerfile:
ENV PAGER=more
Amazing tutorial, thanks
Thank you very very much Andrew