Dockerコンテナで通信するための複数ララベルアプリケーション


version: '3'
services:
  app1_server:
    container_name : "app1_server"
    image : "app1_server"
    build :
      context : "app1"
    ports:
      - 8099:80
    volumes:
      - "./app1:/var/www/app1"
    networks:
      net:
        ipv4_address: 10.5.0.5
  app2_server:
    container_name : "app2_server"
    image : "app2_server"
    build :
      context : "app2"
    ports:
      - 8098:80
    volumes:
      - "./app2:/var/www/app2"
    expose:
      - "80"
    networks:
      net:
        ipv4_address: 10.5.0.6
networks:
  net:
    driver: bridge
    ipam:
     config:
       - subnet: 10.5.0.0/16
         gateway: 10.5.0.1
これで、app 1からapp 2から呼び出すことができます.
たとえば、APP 2の作成テストAPI
Route::get('/api/test', function(){
    return "okay";
});
とAPP 1のルートを作成します.
Route::get('test', function(){   
    $response =  Http::withHeaders([
        'Content-Type' => 'charset=UTF8'
    ])->send('get', 'http://10.5.0.6:80/api/test');
    return $response;
});