Docker networking¶
Table of contents
Introduction¶
Sometimes you might want to connect Hasura running in Docker with APIs (e.g. auth webhooks, event triggers, remote schemas) that are either running outside of Docker or in a different Docker container. Depending on the setting, the network config is different. This section shows how to connect in each of these use cases.
Network config¶
Connection | Config | Comment |
---|---|---|
Hasura to API (outside Docker) |
|
|
API (outside Docker) to Hasura | localhost:8080 |
Hasura runs on port 8080 by default |
Hasura to API (both in docker-compose) | service name, e.g.: api:3000 |
Assuming the API is running on port 3000 |
API to Hasura (both in docker-compose) | service name, e.g.: hasura:8080 |
Hasura runs on port 8080 by default |
Hasura to API (both running with separate docker run) | Docker internal IP address | Can be obtained with docker inspect |
API to Hasura (both running with separate docker run) | Docker internal IP address | Can be obtained with docker inspect |
Connection | Config | Comment |
---|---|---|
Hasura to API (outside Docker) | host.docker.internal:3000 |
Assuming the API is running on port 3000 |
API (outside Docker) to Hasura | localhost:8080 |
Hasura runs on port 8080 by default |
Hasura to API (both in docker-compose) | service name, e.g.: api:3000 |
Assuming the API is running on port 3000 |
API to Hasura (both in docker-compose) | service name, e.g.: hasura:8080 |
Hasura runs on port 8080 by default |
Hasura to API (both running with separate docker run) | Docker internal IP address | Can be obtained with docker inspect |
API to Hasura (both running with separate docker run) | Docker internal IP address | Can be obtained with docker inspect |
Connection | Config | Comment |
---|---|---|
Hasura to API (outside Docker) | docker.for.win.localhost:3000 |
Assuming the API is running on port 3000 |
API (outside Docker) to Hasura | localhost:8080 |
Hasura runs on port 8080 by default |
Hasura to API (both in docker-compose) | service name, e.g.: api:3000 |
Assuming the API is running on port 3000 |
API to Hasura (both in docker-compose) | service name, e.g.: hasura:8080 |
Hasura runs on port 8080 by default |
Hasura to API (both running with separate docker run) | Docker internal IP address | Can be obtained with docker inspect |
API to Hasura (both running with separate docker run) | Docker internal IP address | Can be obtained with docker inspect |
Advanced¶
Learn more about Docker specific networking in the Docker documentation.