Skip to content
This repository has been archived by the owner on Oct 28, 2024. It is now read-only.

Commit

Permalink
fix dns in docker mode
Browse files Browse the repository at this point in the history
  • Loading branch information
davidsiaw committed Jul 16, 2024
1 parent a67f843 commit 4a20c0f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ docker build -t degica/kaiser .
And then add the following line to your `.bashrc` or `.bash_profile`

```
alias kaiser='docker run --pull=always --rm -ti -v /var/run/docker.sock:/var/run/docker.sock -v $HOME/.kaiser:/root/.kaiser -v `pwd`:`pwd` -e CONTEXT_DIR="`pwd`" degicadev/kaiser'
alias kaiser='docker run --pull=always --rm -ti -v /var/run/docker.sock:/var/run/docker.sock -v $HOME/.kaiser:/root/.kaiser -v `pwd`:`pwd` -e _KAISER_USER_HOME=$HOME -e _KAISER_POS=docker -e CONTEXT_DIR="`pwd`" degicadev/kaiser'
```

Or if you use fish

```
function kaiser
docker run --pull=always --rm -ti -v /var/run/docker.sock:/var/run/docker.sock -v $HOME/.kaiser:/root/.kaiser -v (pwd):(pwd) -e CONTEXT_DIR=(pwd) degicadev/kaiser $argv
docker run --pull=always --rm -ti -v /var/run/docker.sock:/var/run/docker.sock -v $HOME/.kaiser:/root/.kaiser -v (pwd):(pwd) -e _KAISER_USER_HOME=$HOME -e _KAISER_POS=docker -e CONTEXT_DIR=(pwd) degicadev/kaiser $argv
end
```

Expand Down
12 changes: 9 additions & 3 deletions lib/kaiser/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -571,8 +571,14 @@ def ensure_setup
jwilder/nginx-proxy"
)

dnsconffile = "#{ENV['HOME']}/.kaiser/dnsconf"
File.write(dnsconffile, <<~HOSTS)
homedir_loc = ENV['HOME']
if ENV['_KAISER_POS'] == 'docker'
homedir_loc = ENV['_KAISER_USER_HOME']
end

innerdnsconffile = "#{ENV['HOME']}/.kaiser/dnsconf"
outerdnsconffile = "#{homedir_loc}/.kaiser/dnsconf"
File.write(innerdnsconffile, <<~HOSTS)
log-queries
no-resolv
server=8.8.8.8
Expand All @@ -585,7 +591,7 @@ def ensure_setup
"docker run -d
--name #{Config.config[:shared_names][:dns]}
--network #{Config.config[:networkname]}
-v #{dnsconffile}:/etc/dnsmasq.conf:ro
-v #{outerdnsconffile}:/etc/dnsmasq.conf:ro
degica/dnsmasq
"
)
Expand Down

0 comments on commit 4a20c0f

Please sign in to comment.