[GH-ISSUE #155] How to use Docker DNS to resolve other containers in compose #142

Closed
opened 2026-03-02 07:28:03 +03:00 by kerem · 2 comments
Owner

Originally created by @chb0github on GitHub (Jul 20, 2019).
Original GitHub issue: https://github.com/hwdsl2/docker-ipsec-vpn-server/issues/155

I am trying to setup something pretty simple in a compose - although it's for a minecraft server, it really could apply to anything so hopefully someone can explain how I can overcome this.

I am trying to use the native docker DNS in a compose so that those who join the VPN can resolve any of the other containers but it's evading me how since the VPN creates another interface which is where all the traffic is going (and straight out to the internet).

Below is my compose, the idea is: connect to the vpn and set your minecraft server to "minecraft" as the host, and you're done.

version: '3.3'
services:
  minecraft:
    build:
      context: .
    restart: always
    hostname: minecraft
    volumes:
      - world:/game/world
      - $PWD/server.properties:/game/server.properties
  vpn:
    image: hwdsl2/ipsec-vpn-server
    entrypoint: /bin/sh
    command: -c "export VPN_DNS_SRV1=$$(cat /etc/resolv.conf | grep nameserver | awk '{print $$2}') && /opt/src/run.sh"
    env_file:
      - settings.env
    restart: always
    hostname: vpn
    ports:
      - 500:500/udp
      - 4500:4500/udp
    privileged: true
volumes:
  world:
Originally created by @chb0github on GitHub (Jul 20, 2019). Original GitHub issue: https://github.com/hwdsl2/docker-ipsec-vpn-server/issues/155 I am trying to setup something pretty simple in a compose - although it's for a minecraft server, it really could apply to anything so hopefully someone can explain how I can overcome this. I am trying to use the native docker DNS in a compose so that those who join the VPN can resolve any of the other containers but it's evading me how since the VPN creates another interface which is where all the traffic is going (and straight out to the internet). Below is my compose, the idea is: connect to the vpn and set your minecraft server to "minecraft" as the host, and you're done. ```yaml version: '3.3' services: minecraft: build: context: . restart: always hostname: minecraft volumes: - world:/game/world - $PWD/server.properties:/game/server.properties vpn: image: hwdsl2/ipsec-vpn-server entrypoint: /bin/sh command: -c "export VPN_DNS_SRV1=$$(cat /etc/resolv.conf | grep nameserver | awk '{print $$2}') && /opt/src/run.sh" env_file: - settings.env restart: always hostname: vpn ports: - 500:500/udp - 4500:4500/udp privileged: true volumes: world: ```
kerem closed this issue 2026-03-02 07:28:03 +03:00
Author
Owner

@hwdsl2 commented on GitHub (Jul 23, 2019):

@chb0github Hello! I see that you are using the correct approach, which involves setting VPN_DNS_SRV1 to your Docker DNS server. You can find more information here [1] [2]. Alternatively you can put the DNS server's hostname in your env file [3].

However, after resolving the DNS, due to Docker's network isolation among containers, I think it is difficult to reach other containers while connected to the IPsec VPN.

[1] https://github.com/hwdsl2/docker-ipsec-vpn-server/pull/95
[2] github.com/hwdsl2/docker-ipsec-vpn-server@d4936ab90d
[3] https://github.com/hwdsl2/docker-ipsec-vpn-server#advanced-usage

<!-- gh-comment-id:514041280 --> @hwdsl2 commented on GitHub (Jul 23, 2019): @chb0github Hello! I see that you are using the correct approach, which involves setting `VPN_DNS_SRV1` to your Docker DNS server. You can find more information here [1] [2]. Alternatively you can put the DNS server's hostname in your `env` file [3]. However, after resolving the DNS, due to Docker's network isolation among containers, I think it is difficult to reach other containers while connected to the IPsec VPN. [1] https://github.com/hwdsl2/docker-ipsec-vpn-server/pull/95 [2] https://github.com/hwdsl2/docker-ipsec-vpn-server/commit/d4936ab90d071c0ceead9f2bc6b7c7cb322bea6e [3] https://github.com/hwdsl2/docker-ipsec-vpn-server#advanced-usage
Author
Owner

@TheAnachronism commented on GitHub (Apr 26, 2021):

Has there been any progress on this?
I'd like to do something very similar...

<!-- gh-comment-id:826769101 --> @TheAnachronism commented on GitHub (Apr 26, 2021): Has there been any progress on this? I'd like to do something very similar...
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/docker-ipsec-vpn-server#142
No description provided.