this post was submitted on 29 Nov 2023
1 points (100.0% liked)

Homelab

371 readers
3 users here now

Rules

founded 1 year ago
MODERATORS
 

I previously installed CoreDNS on a Docker container using the following command:

docker run -d --name coredns --restart=always --volume=/home//Documents/docker/coredns/:/root/ -p 53:53/udp coredns/coredns -conf /root/Corefile

CoreDNS is working just fine on that container.

I'm trying to install CoreDNS on a second container on another host, but for this one I'd like to use a compose file instead of that Docker run command. But I can't figure out how to represent that -conf argument from the run command onto the compose file. Any ideas?

top 2 comments
sorted by: hot top controversial new old
[–] hollowman8904@alien.top 1 points 11 months ago

The bit after the image when running docker run from the command line is the command, which are arguments passed to the container’s entrypoint. So in your case, it would be command: -conf /root/Corefile

https://docs.docker.com/compose/compose-file/compose-file-v3/#command

[–] mrpink57@alien.top 1 points 11 months ago
version: '3'

services:
  coredns:
    image: coredns/coredns
    container_name: coredns
    restart: always
    volumes:
      - /home//Documents/docker/coredns/:/root/
    ports:
      - "53:53/udp"
    command: -conf /root/Corefile

This should do it.