dns-proxy-server icon indicating copy to clipboard operation
dns-proxy-server copied to clipboard

Docker Adapter Provider DpsContainerDAODefault doesn't use a proper IP address range

Open amueller2504 opened this issue 4 months ago • 1 comments

Currently the docker adapter provider DpsContainerDAODefault uses an IMHO invalid IP address range.

https://github.com/mageddo/dns-proxy-server/blob/9c26699337a1008d37474978c02ea0ea733083f6/src/main/java/com/mageddo/dnsproxyserver/solver/docker/dataprovider/DpsContainerDAODefault.java#L86

During the start up of the dns proxy server I see the following error message in the logs:

12:48:28.416 [main           ] ERR com.mageddo.dnsproxyserver.App                    l=40   m=start                           status=fatalError, action=exit, msg=BadRequestException: Status 400: {"message":"invalid network config:\ninvalid ip-range 172.157.5.3/24: it should be 172.157.5.0/24"}
, class=BadRequestException
com.github.dockerjava.api.exception.BadRequestException: Status 400: {"message":"invalid network config:\ninvalid ip-range 172.157.5.3/24: it should be 172.157.5.0/24"}

	at com.github.dockerjava.core.DefaultInvocationBuilder.execute(DefaultInvocationBuilder.java:237)
	at com.github.dockerjava.core.DefaultInvocationBuilder.post(DefaultInvocationBuilder.java:124)
	at com.github.dockerjava.core.exec.CreateNetworkCmdExec.execute(CreateNetworkCmdExec.java:27)
	at com.github.dockerjava.core.exec.CreateNetworkCmdExec.execute(CreateNetworkCmdExec.java:12)
	at com.github.dockerjava.core.exec.AbstrSyncDockerCmdExec.exec(AbstrSyncDockerCmdExec.java:21)
	at com.github.dockerjava.core.command.AbstrDockerCmd.exec(AbstrDockerCmd.java:33)
	at com.mageddo.dnsproxyserver.solver.docker.dataprovider.DpsContainerDAODefault.createDpsNetwork(DpsContainerDAODefault.java:77)
	at com.mageddo.dnsproxyserver.solver.docker.application.DpsDockerEnvironmentSetupService.createNetworkIfAbsent(DpsDockerEnvironmentSetupService.java:61)
	at com.mageddo.dnsproxyserver.solver.docker.application.DpsDockerEnvironmentSetupService.setupNetwork(DpsDockerEnvironmentSetupService.java:48)
	at com.mageddo.dnsproxyserver.solver.docker.application.DpsDockerEnvironmentSetupService.setup(DpsDockerEnvironmentSetupService.java:37)
	at com.mageddo.dnsproxyserver.solver.docker.entrypoint.EventListener.onStart(EventListener.java:31)
	at [email protected]/java.lang.Iterable.forEach(Iterable.java:75)
	at [email protected]/java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1116)
	at com.mageddo.dnsproxyserver.server.Starter.start(Starter.java:30)
	at com.mageddo.dnsproxyserver.di.Context.start(Context.java:64)
	at com.mageddo.dnsproxyserver.App.startContext(App.java:86)
	at com.mageddo.dnsproxyserver.App.mustStart(App.java:61)
	at com.mageddo.dnsproxyserver.App.start(App.java:36)
	at com.mageddo.dnsproxyserver.App.main(App.java:30)
	at [email protected]/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)

I am running the docker container with:

docker run --hostname dns.docker --restart=unless-stopped -d --name=docker-dns \
  -p 5354:53/tcp \
  -p 5354:53/udp \
  -p 5380:5380 \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v /opt/dns-proxy-server/conf:/app/conf \
 defreitas/dns-proxy-server:3.32.4

And having the following basic config:

{
	"version": 2,
	"remoteDnsServers": [],
	"envs": [
		{
			"name": ""
		}
	],
	"activeEnv": "",
	"webServerPort": 0,
	"dnsServerPort": 0,
	"defaultDns": null,
	"logLevel": "TRACE",
	"logFile": "console",
	"registerContainerNames": null,
	"hostMachineHostname": "host.docker",
	"domain": "docker",
	"dpsNetwork": true,
	"dpsNetworkAutoConnect": true
}

Wouldn't it be better to make these settings configurable?

amueller2504 avatar Sep 14 '25 13:09 amueller2504

Hey, thanks for your report.

{"message":"invalid network config:\ninvalid ip-range 172.157.5.3/24: it should be 172.157.5.0/24"}

If docker says it's a invalid range, then let's change it.

Wouldn't it be better to make these settings configurable?

Totally agree, but currently the way to provide a new customizable setting is pretty boring, by this reason I'm working on #594

I expect to get #594 done shortly, then will add that setting.

mageddo avatar Sep 22 '25 18:09 mageddo