DNSCrypt / dnscrypt-server-docker

A Docker image for a non-censoring, non-logging, DNSSEC-capable, DNSCrypt-enabled DNS resolver
https://dnscrypt.info
ISC License
670 stars 135 forks source link

Unable to start the docker container after init when using docker-compose #94

Closed katbyte closed 3 years ago

katbyte commented 3 years ago

This could just be because i am new to docker, but i am having a hard time figuring out how to use the container with docker compose.

Who is the bug affecting?

What is affected by this bug?

starting the docker image (jedisct1/dnscrypt-server) with docker compose after init

How do we replicate the issue?

using this compose file:

  dnscrypt:
    image: jedisct1/dnscrypt-server:latest
    container_name: dnscrypt
    restart: always
    command: "init -N my.domain.com -E 'x.x.x.x:5454'
    ports:
      - "5554:5554/udp"
      - "5554:5554/tcp"
    volumes:
      - /mnt/data/docker/dns/dnscrypt/keys:/opt/encrypted-dns/etc/keys
      - /mnt/data/docker/dns/dnscrypt/etc:/etc/dnscrypt-proxy
    environment:
      - TZ="America/Vancouver"

i get

dnscrypt    | Congratulations! The container has been properly initialized.
dnscrypt    | Take a look up above at the way dnscrypt-proxy has to be configured in order
dnscrypt    | to connect to your resolver. Then, start the container with the default command.

but then how do i start the server? if i change the compose command it recreates the image and asks me to run init again.

Expected behavior (i.e. solution)

Being able to init and then run the container with docker-compose

ianbashford commented 3 years ago

I've just tried to emulate that -- it seemed to work ok for me; after running docker-compose up, I'm left with a running container

cat docker-compose.yml
version: "3"
services:
  dnscrypt:
    image: eanu/dnscrypt-server-docker:1.70
    container_name: dnscrypt
    restart: always
    command: "init -N my.domain.com -E '192.168.3.160:5454'"
    ports:
        - '5554:5554/udp'
        - '5554:5554/tcp'
    volumes:
      - /dev/shm/dns/dnscrypt/keys:/opt/encrypted-dns/etc/keys
      - /dev/shm/dns/dnscrypt/etc:/etc/dnscrypt-proxy
    environment:
    - TZ='UTC'

[that's just a slightly modified version of the docker image you're using]

╭─ian@# /dev/shm/compose  
╰─➤  docker-compose up     
Creating network "compose_default" with the default driver
Creating dnscrypt ... done
Attaching to dnscrypt
dnscrypt    | Provider name: [2.dnscrypt-cert.my.domain.com]
dnscrypt    | [INFO ] Dropping privileges
dnscrypt    | [WARN ] No state file found... creating a new provider key
dnscrypt    | [INFO ] Public server address: 192.168.3.160:5454
dnscrypt    | [INFO ] Provider public key: 012adaf8398c45f29e7778ec1a11421285fc26077df70f2a6858b05f70099781
dnscrypt    | [INFO ] Provider name: 2.dnscrypt-cert.my.domain.com
dnscrypt    | [INFO ] DNS Stamp: sdns://AQcAAAAAAAAAEjE5Mi4xNjguMy4xNjA6NTQ1NCABKtr4OYxF8p53eOwaEUIShfwmB333DypoWLBfcAmXgR0yLmRuc2NyeXB0LWNlcnQubXkuZG9tYWluLmNvbQ
dnscrypt    | 
dnscrypt    | -----------------------------------------------------------------------
dnscrypt    | 
dnscrypt    | Congratulations! The container has been properly initialized.
dnscrypt    | Take a look up above at the way dnscrypt-proxy has to be configured in order
dnscrypt    | to connect to your resolver. Then, start the container with the default command.
╭─ian# /dev/shm/compose  
╰─➤  docker ps -a     
CONTAINER ID   IMAGE                              COMMAND                  CREATED          STATUS                     PORTS                                                                        NAMES
a3c156f45f7d   eanu/dnscrypt-server-docker:1.70   "/entrypoint.sh init…"   10 seconds ago   Up 5 seconds               443/tcp, 9100/tcp, 443/udp, 0.0.0.0:5554->5554/tcp, 0.0.0.0:5554->5554/udp   dnscrypt

That should also leave you with your key storage

╭─ian@# /dev/shm/compose  
╰─➤  ls -ltr /dev/shm/dns/dnscrypt                                                                                                                                          2 ↵
total 0
drwxr-xr-x 2 root root  40 Jan  5 20:29 etc
drwxr-xr-x 3 1001 1001 120 Jan  5 20:29 keys
ianbashford commented 3 years ago

@katbyte I've just moved this to the dnscrypt-server-docker repo

ianbashford commented 3 years ago

@katbyte It occurs to me that it might have worked for me b/c the tweaks I made to the image above was designed for k8s. Perhaps that's why it worked for me. Perhaps you could try that to see if it works - that might help us understand if there are any changes we should make here...

ianbashford commented 3 years ago

Hi @katbyte - did you make any progress?

zquestz commented 3 years ago

A fully working docker-compose.yml has been added to the repo, plus directions in README.md.