guillaumebriday / laravel-blog

Laravel 11.0 blog application with Hotwire, Horizon, Telescope, Sanctum, Breeze and Pusher
https://laravel-blog.guillaumebriday.fr
MIT License
1.75k stars 572 forks source link

Using with Laradock #75

Closed Sogl closed 5 years ago

Sogl commented 5 years ago

Hello!

First of all, thx for your work and this repo. I use Laradock docker configuration for multiple projects: https://laradock.io/getting-started/#B

When I start docker-compose command in this repo I see this error:

Status: Downloaded newer image for redis:alpine
Creating laravel-blog_mysql_1      ... error
Creating laravel-blog_mysql-test_1 ... 
Creating laravel-blog_redis_1      ... 

ERROR: for laravel-blog_mysql_1  Cannot start service mysql: driver failed 
programming external connectivity on endpointCreating laravel-blog_mysql-test_1 ... done
Creating laravel-blog_redis_1      ... done

ERROR: for mysql  Cannot start service mysql: driver failed programming external 
connectivity on endpoint laravel-blog_mysql_1
(0c8fbc7a8fd55ccd1bb7a72a5728c791bd073f0174b360e390a2363ade523b0d): Bind 
for 0.0.0.0:3306 failed: port is already allocated
ERROR: Encountered errors while bringing up the project.

When I docker-compose down in Laradock and docker-compose up yours, all works fine, BUT I can't use my own project 😞 I want to start both projects on my host machine.

Also I have differences in my Laradock conf:

Any ideas? Build MySQL with another port?

guillaumebriday commented 5 years ago

for 0.0.0.0:3306 failed: port is already allocated

I think you have another mysql container started, right ?

guillaumebriday commented 5 years ago

I will take a look a laradock, thanks

Sogl commented 5 years ago

Yep, another mysql container (in Laradock) is started when I see this error.

guillaumebriday commented 5 years ago

you cannot bind 2 containers to the same port.

Either change the port or stop your laradock container before

Sogl commented 5 years ago

Change this line: https://github.com/guillaumebriday/laravel-blog/blob/903b4a42a401e15d365c54629faa86c630493067/docker-compose.yml#L27

to 3308:3308?

What I found in Laradock manual: https://laradock.io/documentation/#change-mysql-port

guillaumebriday commented 5 years ago

"3308:3306"

and change your config in .env file

Does it work ?

Sogl commented 5 years ago

Finally works with 3308:3306.

Config in .env (strange, but 127.0.0.1 works in TablePlus, but not in Laravel):

DB_CONNECTION=mysql
DB_HOST=mysql
DB_DATABASE=laravel-blog
DB_USERNAME=root
DB_PASSWORD=secret

Thank you for your help! 😉

p.s. Maybe need to add a manual for Laradock users? For me it's more useful for different types of Laravel projects.

guillaumebriday commented 5 years ago

There is nothing strange in this config, you need to use 127.0.0.1 in TablePlus because it's not inside the docker network.

In other hand, you can use mysql in .env because it's inside docker. :)

I won't add a manual Laradock because it's not related to Laradock nor to this project but it's the way ports on linux work.

Thank you @Sogl

Sogl commented 5 years ago

There is nothing strange in this config, you need to use 127.0.0.1 in TablePlus because it's not inside the docker network.

In other hand, you can use mysql in .env because it's inside docker. :)

Now it's clear. Thx!