Thank you for making this video. I've watched many hours of Docker tutorials this week after learning the basics, and this has been the only tutorial where things were explained very clearly. The bit about how to set up an nginx config file was invaluable.
@@GaryClarkeTech Thank you! I do have one question though (if you don't mind taking a moment to answer). I'm fairly new to Docker, and I'm having an issue using the setup in this video where every other PHP page in the public folder returns a 404, except the index page. For example, localhost:8080/example.php returns a 404. I changed some things in the nginx config file to possibly remedy this (like the part at the bottom that forces a 404 on everything but index.php), but that just makes me download my script when I go to that script's page. Do you know why this is still happening, and how to fix it?
Actually, I solved this by doing some trial and error with my config script. Stack Overflow helped a lot too, but ultimately I just had to put the things from the location index.php brackets into a new "location" that looks like this: location ~ \.php$ (I suppose this is for any file/page that ends in .php).
This should help me! I've been trying to do this on my own for all day (except the node part, but I'll keep it on mind, it'll maybe be useful for a future project) switching between apache and nginx, both resulting in the same error : fcgi returning error. Gonna try ur solution tomorrow, I hope it works this time! Your tutorial is really good anyway, you explain well with a very comprehensive English for a French student like me. Thanks a lot for that!
Update : it worked ! thank you so much for this vid. I just had to make a few changes, like choosing a more recent version of php and edit the Dockerfile for the php container (the mv instruction is returning an error since now it's not /root/.symfony/(...) but /root/.symfony5/(...)
@@phoenlx_3 Hey that's awesome..so glad it worked! This video is over 2 years old now so I am currently working on a new PHP + Docker tutorial which will use PHP MySQL Nginx and Redis and I'm also gonna show how to push the app to production on AWS. You'll really like it.
thank you so much for this guide, few guides work right away and are modifiable for other projects. you have nailed it. keep up the great work my friend.
Thsnk you very much, you are my hero. I was traying to init a symfony app with docker and i was having a lot of problem to serve the statics files. Thansk to you I have succeeded :))))))
Great video - it worked first time for me so I was super happy .... I hate configurating things, but this made it easy. Thank you for saving me a headache :)
Only that I don't know a lot about it 😂 It's not my area of expertise. But I'm gonna do more Docker in about 3 months so I'll upskill before then. Feel free to share any links on the subject!
Hi Gary, thanks, it is a great tutorial. I learned a lot. However, I ran into problem with php installation. While trying to figure out what went wrong, I realized, you were installing the docker on macOS so your dependencies are different then mine. I am using docker on windows 10 with WSL2 is "Debian10" for my port. So the requirements must be different. I did not however follow the recommended Debian way of installing PHP. I did trial and error. Here is what I did.... FROM php:7.4-fpm RUN apt-get update && apt-get install -y zlib1g-dev git libicu-dev zip libzip-dev zip \ && docker-php-ext-install intl opcache pdo pdo_mysql \ && pecl install apcu \ && docker-php-ext-enable apcu \ && docker-php-ext-install zip
@@GaryClarkeTech it seems lot of it has changed after your tutorial. Windows, WSL selection, Symphony everywhere there are lot of update. Maybe you can do a new tutorial on windows, to catch all the changes. However, do a Symphony tutorial. From basic to advance. I like your style. Thank you.
Thank you for great explanation! I've done it all, but the localhost page didn;t show me that echo from index. It says that "Welcome to nginx! Nginx installed and working, but needs to be configured". Do you have any ideas where I could've made a mistake? One thing if it's matters: I've typed php80 sign everywhere, not php74
I'm not sure...it could be a number of things. The best solution will be to pull my files from github and try those first. Then figure out what the difference is between them and yours.
@@GaryClarkeTech I tried it, now I'm getting "File not found" on that localhost page. Maybe I need to add the path in nano /etc/hosts? but it seems like localhost is already there. Anyway, thanks for the reply and advice Gary!
Hello, thanks for the tutorial but I have some questions, my app is verly slow (loading on browser taking long time and also running commands on CLI) does the fact that Im using volumes that slows everything ? (Im using docker desktop on windows)
Hy Gary, great tutorial. However, I meet an error when I run the first docker-compose command: [...]:~/project$ docker-compose up -d --build Creating network "project_nginx-php74-mysql8-node" with the default driver Building php74-service [+] Building 7.7s (3/3) FINISHED => [internal] load build definition from Dockerfile 0.9s => => transferring dockerfile: 596B 0.0s => [internal] load .dockerignore 1.2s => => transferring context: 2B 0.0s => ERROR [internal] load metadata for docker.io/library/php:7.4-fpm Do you have any idea where this might come from? Thanks a lot.
It's just a container which is built using a node image. the name node-container is a custom name which I gave to it...it's not essential. The main reason that I included it in the project was for frontend asset compilation...which you can learn all about in part 2. Enjoy!
just letting you know, on windows if I establish nginx volume conf like this "- ./nginx/default.conf:/etc/nginx/conf.d/default.conf" then it complains that I'm trying to mount a directory onto a file, this is the solution stackoverflow.com/questions/59018610/docker-error-cannot-start-service-nginx-oci-runtime-create-failed
@@GaryClarkeTech Or better yet map it like this "- ./nginx/conf.d:/etc/nginx/conf.d" because otherwise it makes a separate config folder and doesn't use default.conf that you provide. At least that's how I made it work, I'm open to suggestions :)
Hey Abdul...I wanna help you but can you give me a bit more info? e.g. At what point is it happening? What steps have you taken to fix it so far? What results did you get from your debugging?
@@GaryClarkeTech I didn't create the app folder that's working now, but now if I have a sub dir inside /app like /app/mydir/abc.html, I can't view that file from localhost:8080/app/mydir/abc.html, and nginx show the same file i.e index.php like you showed in the tutorial.
thanks a lot that was easy and great. But I had problem when run mysql it kept restarting with error message : " [ERROR] [Entrypoint]: MYSQL_USER="root", MYSQL PASSWORD cannot be used for the root user Use one of the following to control the root user password: - MYSQL_ROOT_PASSWORD - MYSQL_ALLOW_EMPTY_PASSWORD - MYSQL_RANDOM_ROOT_PASSWORD " But when I commented MYSQL_USER: root and MYSQL_PASSWORD: secret it worked. I did not understand why but it works lol
MYSQL_ALLOW_EMPTY_PASSWORD is quite a common setting in dev so you could use that Not knowing why something works is scarier than not knowing why it doesn't 😂
If you encounter any breaks with webpack encore when using node v15, try changing docker-compose.yaml to specify node:14
I was looking for something like this for a while, here i found everything. Great tutorial.
Awesome, thank you!
Thank you for making this video. I've watched many hours of Docker tutorials this week after learning the basics, and this has been the only tutorial where things were explained very clearly. The bit about how to set up an nginx config file was invaluable.
Hey Jahoopy that's great. I'm glad I was able to help 🤝
@@GaryClarkeTech Thank you!
I do have one question though (if you don't mind taking a moment to answer). I'm fairly new to Docker, and I'm having an issue using the setup in this video where every other PHP page in the public folder returns a 404, except the index page. For example, localhost:8080/example.php returns a 404. I changed some things in the nginx config file to possibly remedy this (like the part at the bottom that forces a 404 on everything but index.php), but that just makes me download my script when I go to that script's page.
Do you know why this is still happening, and how to fix it?
Actually, I solved this by doing some trial and error with my config script. Stack Overflow helped a lot too, but ultimately I just had to put the things from the location index.php brackets into a new "location" that looks like this: location ~ \.php$ (I suppose this is for any file/page that ends in .php).
@@jahoopyjaheepu497 Glad you figured it out!
Great explanation with a very relaxed and easy to understand vibe!
Thank you and keep the excelent work.
Thanks Gonçalo...appreciate it!
Thanks for the effort, Gary. I was able to get it running in no time!
Great news..nice work!
This should help me! I've been trying to do this on my own for all day (except the node part, but I'll keep it on mind, it'll maybe be useful for a future project) switching between apache and nginx, both resulting in the same error : fcgi returning error.
Gonna try ur solution tomorrow, I hope it works this time!
Your tutorial is really good anyway, you explain well with a very comprehensive English for a French student like me. Thanks a lot for that!
Update : it worked ! thank you so much for this vid. I just had to make a few changes, like choosing a more recent version of php and edit the Dockerfile for the php container (the mv instruction is returning an error since now it's not /root/.symfony/(...) but /root/.symfony5/(...)
@@phoenlx_3 Hey that's awesome..so glad it worked! This video is over 2 years old now so I am currently working on a new PHP + Docker tutorial which will use PHP MySQL Nginx and Redis and I'm also gonna show how to push the app to production on AWS. You'll really like it.
Great teachter is mister Clarke!
thank you so much for this guide, few guides work right away and are modifiable for other projects. you have nailed it. keep up the great work my friend.
Awesome, thank you!
@@GaryClarkeTech no my friend thank you!
Thsnk you very much, you are my hero. I was traying to init a symfony app with docker and i was having a lot of problem to serve the statics files. Thansk to you I have succeeded :))))))
Glad I could help...I'll probably release an updated Symfony + Docker video in the next few months
Hey Gary, this is a great tutorial, thanks for that!
Thanks buddy, I appreciate that. There'll be more to come so be sure to subscribe!
Great video - it worked first time for me so I was super happy .... I hate configurating things, but this made it easy. Thank you for saving me a headache :)
Glad to save you a headache 🤯
Could not be better. Thank you so much
Thank you very much for your video. Very easy to understand the base concept!
You're welcome, David..and thank you!
Exactly what i need to set up ! i'm excited, Thanks you so much.
You're welcome, friend. Glad I could help!
Hello Gary. Is there any reason for you not to use the unix socket for connecting php-fpm and nginx?
Only that I don't know a lot about it 😂 It's not my area of expertise. But I'm gonna do more Docker in about 3 months so I'll upskill before then. Feel free to share any links on the subject!
Amazing tutorial! Thank you very much!
Thanks for this awesome tutorial !
My pleasure!
Thank you so much!!! Everything works at once! 🥰
Amazing! The video is nearly a year old now, so I'm glad to hear everything still works!
Thank you for sharing, it is a great video. What if I have multiple sites under Nginx, and want to keep each host conf in separate file?
Thank you, you're welcome. You mean multiple sites on one nginx service? I've always stuck to one site per service.
very clear, thanks man!
This is such a good video, thanks!
Glad it helped!
Hi Gary, thanks, it is a great tutorial. I learned a lot. However, I ran into problem with php installation. While trying to figure out what went wrong, I realized, you were installing the docker on macOS so your dependencies are different then mine. I am using docker on windows 10 with WSL2 is "Debian10" for my port. So the requirements must be different. I did not however follow the recommended Debian way of installing PHP. I did trial and error.
Here is what I did....
FROM php:7.4-fpm
RUN apt-get update && apt-get install -y zlib1g-dev git libicu-dev zip libzip-dev zip \
&& docker-php-ext-install intl opcache pdo pdo_mysql \
&& pecl install apcu \
&& docker-php-ext-enable apcu \
&& docker-php-ext-install zip
Thanks Mohammad. I hope you managed to get it to work for you.
@@GaryClarkeTech it seems lot of it has changed after your tutorial. Windows, WSL selection, Symphony everywhere there are lot of update. Maybe you can do a new tutorial on windows, to catch all the changes.
However, do a Symphony tutorial. From basic to advance. I like your style.
Thank you.
Thank you for great explanation!
I've done it all, but the localhost page didn;t show me that echo from index. It says that "Welcome to nginx! Nginx installed and working, but needs to be configured". Do you have any ideas where I could've made a mistake?
One thing if it's matters: I've typed php80 sign everywhere, not php74
I'm not sure...it could be a number of things.
The best solution will be to pull my files from github and try those first. Then figure out what the difference is between them and yours.
@@GaryClarkeTech I tried it, now I'm getting "File not found" on that localhost page. Maybe I need to add the path in nano /etc/hosts? but it seems like localhost is already there. Anyway, thanks for the reply and advice Gary!
What if you need to change something does it take effect immediately or its like you need to restart the docker again
You won't need to restart for things that are volume-mounted like your src code. For some other things you may have to
Hi brother, my node container doesn't run at all, the rest are fine. thanks for tutorial
It could possibly be a compatibility issue with a later version of node than the one used in the video.
Hello, thanks for the tutorial but I have some questions, my app is verly slow (loading on browser taking long time and also running commands on CLI) does the fact that Im using volumes that slows everything ? (Im using docker desktop on windows)
php + docker can be slow on windows but I hear that the latest version of Docker is much quicker.
Thank you
You're welcome
Nice!
Why do we need node for symfony ?
Hy Gary,
great tutorial. However, I meet an error when I run the first docker-compose command:
[...]:~/project$ docker-compose up -d --build
Creating network "project_nginx-php74-mysql8-node" with the default driver
Building php74-service
[+] Building 7.7s (3/3) FINISHED
=> [internal] load build definition from Dockerfile 0.9s
=> => transferring dockerfile: 596B 0.0s
=> [internal] load .dockerignore 1.2s
=> => transferring context: 2B 0.0s
=> ERROR [internal] load metadata for docker.io/library/php:7.4-fpm
Do you have any idea where this might come from?
Thanks a lot.
Thanks bro!
You're welcome!
@@GaryClarkeTech Short and clear info
What is the meaning of node container?
It's just a container which is built using a node image. the name node-container is a custom name which I gave to it...it's not essential. The main reason that I included it in the project was for frontend asset compilation...which you can learn all about in part 2. Enjoy!
@@GaryClarkeTech thanks for the quick response!
@@derzskyi1 Welcome buddy
Hi Sir, I am getting error "502 Bad Gateway / nginx/1.22.0"
can you help me on this please?
show!, fantastical
just letting you know, on windows if I establish nginx volume conf like this "- ./nginx/default.conf:/etc/nginx/conf.d/default.conf" then it complains that I'm trying to mount a directory onto a file, this is the solution stackoverflow.com/questions/59018610/docker-error-cannot-start-service-nginx-oci-runtime-create-failed
Thanks for the heads up Belkin..appreciated. I'll check it out.
@@GaryClarkeTech Or better yet map it like this "- ./nginx/conf.d:/etc/nginx/conf.d" because otherwise it makes a separate config folder and doesn't use default.conf that you provide. At least that's how I made it work, I'm open to suggestions :)
My nginx container immediately exits?
never mind, i missed a semicolon when setting the fastcgi_pass .
also, mounting those logs is useful, they helped me debug this
Definitely...server config is never straight forward for me! I'm glad you got it working.
Hi Gary, I am getting this "File not found." on localhost:8080/ , can you please help me.
Hey Abdul...I wanna help you but can you give me a bit more info?
e.g. At what point is it happening? What steps have you taken to fix it so far? What results did you get from your debugging?
@@GaryClarkeTech I didn't create the app folder that's working now,
but now if I have a sub dir inside /app like /app/mydir/abc.html, I can't view that file from localhost:8080/app/mydir/abc.html, and nginx show the same file i.e index.php like you showed in the tutorial.
hi abdul , how do you solve his. i have a same error
@@yanndeo9501 you need to create app folder then create the index files inside that so that server can serve it.
@@abdulmobeen2477 yes i have a app folder like this : app/public/index.php ; i'am getting file not found and node-container not run
+
Not working for me... 🥵
thanks a lot that was easy and great. But I had problem when run mysql it kept restarting with error message :
"
[ERROR] [Entrypoint]: MYSQL_USER="root", MYSQL PASSWORD cannot be used for the root user Use one of the following to control the root user password: - MYSQL_ROOT_PASSWORD - MYSQL_ALLOW_EMPTY_PASSWORD - MYSQL_RANDOM_ROOT_PASSWORD
"
But when I commented MYSQL_USER: root and MYSQL_PASSWORD: secret it worked. I did not understand why but it works lol
MYSQL_ALLOW_EMPTY_PASSWORD is quite a common setting in dev so you could use that
Not knowing why something works is scarier than not knowing why it doesn't 😂
Lol! I don't like the say: if it's works don't touch it also. Thanks again 😊