socat-dns-docker/README.md

60 lines
1.7 KiB
Markdown

# socat-dns-docker
[![Build Status](https://jenkins.sudo.is/buildStatus/icon?job=ben%2Fsocat-dns-docker%2Fmain&style=flat-square)](https://jenkins.sudo.is/job/ben/job/socat-dns-docker/)
[![git](https://git.sudo.is/ben/infra/media/branch/main/docs/img/shields/git.sudo.is-ben.svg)](https://git.sudo.is/ben/socat-dns-docker)
[![github](https://git.sudo.is/ben/infra/media/branch/main/docs/img/shields/github-benediktkr.svg)](https://github.com/benediktkr/socat-dns-docker)
[![matrix](https://git.sudo.is/ben/infra/media/branch/main/docs/img/shields/darkroom.svg)](https://matrix.to/#/#darkroom:sudo.is)
[![BSD-3-Clause-No-Military-License](https://git.sudo.is/ben/infra/media/branch/main/docs/img/shields/license-BSD-blue.svg)](LICENSE)
use [`socat`](http://www.dest-unreach.org/socat/) to forward to the
dns server of a bridged docker network.
this is a pretty simple docker image. you can simply clone [this
repo](https://git.sudo.is/ben/socat-dns-docker) and build the
container:
```
docker build -t socat-dns:latest
# run the container
network="bridge"
container_ip="172.17.0.10"
docker run -d --rm -it \
--network="$network" \
--ip "$container_ip"
--name socatdns -p 127.0.0.1:53:5353 \
socat-dns:latest
```
then you can send a query to container from the host:
```
$ dig socatdns @172.17.0.10 -p 5353 +short
172.17.0.10
```
or use the port forwarded to `loclahost`:
```
$ dig socatdns @127.0.0.1 +short
177.17.0.10
```
## examples
use the pre-built container with a `docker-compose.yml` file:
```yaml
version: '3'
services:
socatdns:
image: git.sudo.is/ben/socat-dns:latest
container_name: socatdns
restart: always
ports:
- 127.0.0.1:5353:53
```