Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rednafi/docker-local-subdomain
Locally access Docker services as 'subdomain.localhost' instead of 'localhost:port'
https://github.com/rednafi/docker-local-subdomain
dns docker express nodejs
Last synced: 8 days ago
JSON representation
Locally access Docker services as 'subdomain.localhost' instead of 'localhost:port'
- Host: GitHub
- URL: https://github.com/rednafi/docker-local-subdomain
- Owner: rednafi
- Created: 2022-05-15T07:36:19.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-08T12:42:16.000Z (7 months ago)
- Last Synced: 2024-04-08T13:49:13.254Z (7 months ago)
- Topics: dns, docker, express, nodejs
- Language: Python
- Homepage:
- Size: 689 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Docker Local Subdomain
Ever had a hard time remembering the port numbers of different services in your local
[Docker](https://docs.docker.com/) stack? This example demonstrates how you can access
the services via `.localhost` instead of `localhost:`.*This is a simple node stack running two [Express](https://expressjs.com/) servers in two
different containers. You can access the services via `foo.localhost` and `bar.localhost`
respectively. Here, [Caddy](https://caddyserver.com/) is used as a reverse proxy to
direct the requests to the appropriate containers.*## Prerequisites
This example assumes that you're running a Unix system with Docker >= 20.10.15, Docker
compose v2, [cURL](https://curl.se/), and [jq](https://stedolan.github.io/jq/) installed.## Installation
Clone the repo, go to the root directory, and run:
```
make up
```This will spin up three containers—a single reverse proxy and two application containers.
## Usage
You can make requests to the containers as follows:
```bash
curl -s -X GET http://foo.localhost | jq
```This returns:
```json
{
"status": "ok",
"statusCode": 200,
"containerIP": "219.20.128.1",
"message": "Hello world from container 1"
}
```Similarly, you can access the second service as follows:
```bash
curl -s -X GET http://bar.localhost | jq
```This returns:
```json
{
"status": "ok",
"statusCode": 200,
"containerIP": "219.20.128.2",
"message": "Hello world from container 2"
}
```Here, the containers have static IPs and you can see that the two requests are handled
by two different containers.## Todo
* Add caching to the CI.