Docker isn't the issue here. You don't know how to deploy a laravel application. If you can't do that, you won't be able to do the steps necessary to create a production ready image https://mobdro.bio/ .
Jul 20, 2023
4
Level 10
connect Laravel apps locally with Docker via Console
Hello , I have been using this method of Andrew Schmelyun
https://www.youtube.com/watch?v=LFrBmvgamGI
to connectone laravel project to other with docker .
this is the code -
$client = new Client;
$request = $client->get('http://laravel_server:80/api/test-connection"');
$response = $request->getBody()->getContents();
well , it is working . if I access via browser ( via http ) But if ,I run in console instead brouser . it gives error
via console , the same code does not work . I did a command -
docker-compose run --rm artisan create:my-comand
and gives this error -
GuzzleHttp\Exception\ConnectException
cURL error 6: Could not resolve host: elk_server (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for http://laravel_server/api/test-connection
at vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php:210
206▕ }
207▕
208▕ // Create a connection exception if it was a specific error code.
209▕ $error = isset($connectionErrors[$easy->errno])
➜ 210▕ ? new ConnectException($message, $easy->request, null, $ctx)
211▕ : new RequestException($message, $easy->request, $easy->response, null, $ctx);
212▕
213▕ return P\Create::rejectionFor($error);
214▕ }
+14 vendor frames
15 app/Console/Commands/CreateStatisticPropertyActions.php:42
GuzzleHttp\Client::get("http://laravel_server:80/api/test-connection")
+13 vendor frames
29 artisan:37
I tryed as well withh HTTP clas -
Http::get("laravel_server:80/api/test-connection");
the same error happens
Please or to participate in this conversation.