Internal Networking
Instantly.run supports internal networking to simplify communication between containers. This guide explains how internal hostnames are configured and how to use them.
Internal Hostnames
Each container deployed through Instantly.run is assigned an internal hostname based on its configured domain name. The internal hostname is derived by replacing dots (.
) with hyphens (-
).
Examples
- Public Domain:
db.example.com
- Internal Hostname:
db-example-com
This internal hostname is accessible to other containers within the same network.
Using Internal Hostnames
Internal hostnames can be used to connect to services that are not exposed to the public (e.g., databases, caching servers, etc.).
Example: Connecting to a MongoDB Instance
-
Deploy the MongoDB Container:
docker run --context=instantly --name mongo-db --domainname db.example.com \ -e MONGO_INITDB_ROOT_USERNAME=admin -e MONGO_INITDB_ROOT_PASSWORD=securepassword \ -p 27017:27017 -v ssd:/data/db
-
Access the MongoDB Service from Another Container: Use the internal hostname to connect:
mongodb://admin:securepassword@db-example-com:27017
Networking for Non-HTTP Services
Non-HTTP services like databases and messaging queues are accessible internally using their internal hostname and respective port.
Example: Redis Instance
-
Deploy the Redis Container:
docker run --context=instantly --name redis-cache --domainname cache.example.com \ -p 6379:6379 -v ssd:/data
-
Access Redis from Another Container: Use the internal hostname:
redis://cache-example-com:6379
Limitations
- Internal hostnames are only resolvable by other containers within the same network.
- Public access to non-HTTP services is not supported. These services are limited to internal use.