Hello!
I am running my web application in a Docker container on my local PC. The application creates users via Keycloak REST API. Keycloak is hosted in a container on a remote server (http, no reverse proxy).
The issue is that I am not able to reach Keycloak from the application container. It always returns 404 regardless of route. The container has access to the Internet. Other http/https web resources are reachable via curl. If I try to reach Keycloak from my local PC (not from the contrainer) it is reachable.
From container:
root@32eb86022963:/app# curl http://<hostname>/
{"error":"RESTEASY003210: Could not find resource for full path: http://<hostname>http://<hostname>/"}
From local PC:
C:\Users\siwi1>curl http://<hostname>/
<!--
~ JBoss, Home of Professional Open Source.
~ Copyright (c) 2011, Red Hat, Inc., and individual contributors
~ as indicated by the @author tags. See the copyright.txt file in the
~ distribution for a full listing of individual contributors.
~
Could someone advise why I cannot reach Keycloak from the docker container?
Keycloak docker-compose setup:
version: '3.9'
services:
keycloak-postgres:
image: library/postgres:${KC_POSTGRES_IMAGE_TAG:-14}
container_name: ${POSTGRES_CONTAINER_NAME:-postgres}
restart: on-failure
environment:
POSTGRES_USER: ...
POSTGRES_PASSWORD: ...
POSTGRES_DB: postgres
healthcheck:
test: pg_isready -d postgres
interval: 10s
timeout: 5s
retries: 3
start_period: 5s
ports:
- ${KC_POSTGRES_PORT_MAPPING:-5435}:5432
deploy:
resources:
limits:
memory: 256M
keycloak:
image: quay.io/keycloak/keycloak:20.0.2
container_name: keycloak
command:
- start --auto-build --db postgres --hostname-strict-https false --hostname-strict false --proxy edge --http-enabled true --import-realm --spi-user-profile-legacy-user-profile-read-only-attributes *_RES_ACCESS_MODE
environment:
KC_DB_URL: jdbc:postgresql://keycloak-postgres:5432/postgres
KC_DB_USERNAME: ...
KC_DB_PASSWORD: ...
KC_DB_SCHEMA: public
KC_FEATURES: preview
KEYCLOAK_ADMIN: ...
KEYCLOAK_ADMIN_PASSWORD: ...
ports:
- 80:8080
depends_on:
keycloak-postgres:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://0.0.0.0:8080/realms/master"]
start_period: 10s
interval: 30s
retries: 3
timeout: 5s
I appreciate your help!