I have this krakend.json:
{
"$schema": "https://www.krakend.io/schema/v2.4/krakend.json",
"version": 3,
"port": 8080,
"host": ["http://localhost:8080"],
"endpoints": [
{
"@comment": "Bla bla",
"endpoint": "/app/{identification}",
"backend": [
{
"host": ["http://localhost:4802"],
"url_pattern": "/app/{identification}"
}
]
}
]
}
my docker-compose.yml:
version: "3"
services:
krakend_ce:
# The :watch image restarts the service automatically when the configuration files change.
# Do not use this image in production, it's meant to speed up your testing and development.
image: devopsfaith/krakend:watch
volumes:
- .:/etc/krakend
ports:
- "1234:1234"
- "8080:8080"
- "8090:8090"
command: ["run", "-d", "-c", "/etc/krakend/krakend.json"]
depends_on:
- myservice
myservice:
image: myservice:latest
volumes:
- ./config/application.yaml:/usr/application/config/application.yaml:ro
- ./logs:/usr/application/logs
ports:
- "4802:4802"
Those containers:
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a8b301aed1c3 devopsfaith/krakend:watch "/entrypoint.sh run …" 2 minutes ago Up 6 seconds 0.0.0.0:1234->1234/tcp, :::1234->1234/tcp, 0.0.0.0:8080->8080/tcp, :::8080->8080/tcp, 0.0.0.0:8090->8090/tcp, :::8090->8090/tcp myservice_krakend_ce_1
a1cd2e890510 myservice:latest "java -Djava.securit…" 28 minutes ago Up 28 minutes 0.0.0.0:4802->4802/tcp, :::4802->4802/tcp myservice_1
The log:
docker logs -f a8b301aed1c3
Watching changes on files /etc/krakend/
Ignoring saves to file out.json
[00] Starting service
[00] Parsing configuration file: /etc/krakend/krakend.json
[00] 2023/09/20 12:29:45 KRAKEND INFO: Starting KrakenD v2.4.3
[00] 2023/09/20 12:29:45 KRAKEND DEBUG: [SERVICE: Gin] Debug enabled
[00] 2023/09/20 12:29:45 KRAKEND INFO: Starting the KrakenD instance
[00] 2023/09/20 12:29:45 KRAKEND DEBUG: [ENDPOINT: /app/:identification] Building the proxy pipe
[00] 2023/09/20 12:29:45 KRAKEND DEBUG: [BACKEND: /app/{{.identification}}] Building the backend pipe
[00] 2023/09/20 12:29:45 KRAKEND DEBUG: [ENDPOINT: /app/:identification] Building the http handler
[00] 2023/09/20 12:29:45 KRAKEND DEBUG: [ENDPOINT: /app/:identification][JWTSigner] Signer disabled
[00] 2023/09/20 12:29:45 KRAKEND INFO: [ENDPOINT: /app/:identification][JWTValidator] Validator disabled for this endpoint
[00] 2023/09/20 12:29:45 KRAKEND INFO: [SERVICE: Gin] Listening on port: 8080
[00] [GIN] 2023/09/20 - 12:30:07 | 200 | 122.211µs | 172.18.0.1 | GET "/__health"
[00] [GIN] 2023/09/20 - 12:30:08 | 200 | 28.809µs | 172.18.0.1 | GET "/__health"
[00] [GIN] 2023/09/20 - 12:30:09 | 200 | 53.791µs | 172.18.0.1 | GET "/__health"
[00] 2023/09/20 12:30:16 KRAKEND ERROR: [ENDPOINT: /app/:identification] Get "http://localhost:4802/app/110033323312176": dial tcp 127.0.0.1:4802: connect: connection refused
[00] [GIN] 2023/09/20 - 12:30:16 | 500 | 703.485µs | 172.18.0.1 | GET "/app/110033323312176"
[00] Error #01: Get "http://localhost:4802/app/110033323312176": dial tcp 127.0.0.1:4802: connect: connection refused
[00] 2023/09/20 12:30:16 KRAKEND ERROR: [ENDPOINT: /app/:identification] Get "http://localhost:4802/app/110033323312176": dial tcp 127.0.0.1:4802: connect: connection refused
[00] [GIN] 2023/09/20 - 12:30:16 | 500 | 541.71µs | 172.18.0.1 | GET "/app/110033323312176"
[00] Error #01: Get "http://localhost:4802/app/110033323312176": dial tcp 127.0.0.1:4802: connect: connection refused
Watching changes on files /etc/krakend/
Ignoring saves to file out.json
[00] Starting service
[00] Parsing configuration file: /etc/krakend/krakend.json
[00] 2023/09/20 12:31:59 KRAKEND INFO: Starting KrakenD v2.4.3
[00] 2023/09/20 12:31:59 KRAKEND DEBUG: [SERVICE: Gin] Debug enabled
[00] 2023/09/20 12:31:59 KRAKEND INFO: Starting the KrakenD instance
[00] 2023/09/20 12:31:59 KRAKEND DEBUG: [ENDPOINT: /app/:identification] Building the proxy pipe
[00] 2023/09/20 12:31:59 KRAKEND DEBUG: [BACKEND: /app/{{.identification}}] Building the backend pipe
[00] 2023/09/20 12:31:59 KRAKEND DEBUG: [ENDPOINT: /app/:identification] Building the http handler
[00] 2023/09/20 12:31:59 KRAKEND DEBUG: [ENDPOINT: /app/:identification][JWTSigner] Signer disabled
[00] 2023/09/20 12:31:59 KRAKEND INFO: [ENDPOINT: /app/:identification][JWTValidator] Validator disabled for this endpoint
[00] 2023/09/20 12:31:59 KRAKEND INFO: [SERVICE: Gin] Listening on port: 8080
[00] 2023/09/20 12:33:15 KRAKEND ERROR: [ENDPOINT: /app/:identification] Get "http://localhost:4802/app/110033323312176": dial tcp 127.0.0.1:4802: connect: connection refused
[00] [GIN] 2023/09/20 - 12:33:15 | 500 | 1.070179ms | 172.18.0.1 | GET "/app/110033323312176"
[00] Error #01: Get "http://localhost:4802/app/110033323312176": dial tcp 127.0.0.1:4802: connect: connection refused
[00] 2023/09/20 12:33:52 KRAKEND ERROR: [ENDPOINT: /app/:identification] Get "http://localhost:4802/app/110033323312176": dial tcp 127.0.0.1:4802: connect: connection refused
[00] [GIN] 2023/09/20 - 12:33:52 | 500 | 530.808µs | 172.18.0.1 | GET "/app/110033323312176"
[00] Error #01: Get "http://localhost:4802/app/110033323312176": dial tcp 127.0.0.1:4802: connect: connection refused
I called: http://localhost:8080/app/110033323312176 and i got an error.
You are making KrakenD connect to
http://localhost:4802.This port does not exist in the KrakenD container, but in your application container. You should change the configuration to: