Skip to content

Commit 5956f1e

Browse files
committed
disable systemd/firewall in docker
1 parent 3672cd7 commit 5956f1e

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ When running inside Docker container, we don't want to use random ports, so we n
2525
```bash
2626
docker run -d \
2727
--name lantern-server-manager \
28+
-e NO_FIREWALLD=true \
29+
-e NO_SYSTEMD=true
2830
-p 8080:8080 \
2931
-p 1234:1234 \
3032
-v /path/to/config:/config \
31-
getlantern/lantern-server-manager -d /config --vpn-port 1234 --api-port 8080 serve
33+
getlantern/lantern-server-manager -d /config --vpn-port 1234 --api-port 8080
3234
```
3335

3436
### Digital Ocean

cmd/cmd_init.go

+9
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"github.com/charmbracelet/log"
66
"github.com/sagernet/sing-box/option"
7+
"os"
78
"os/exec"
89

910
"github.com/getlantern/lantern-server-manager/common"
@@ -34,7 +35,15 @@ func (c InitCmd) Run() error {
3435
return nil
3536
}
3637

38+
// attemptToOpenPorts uses firewall-cmd to open required ports.
39+
// NO_FIREWALLD skips this. This is useful for local testing or within docker
40+
var noFirewallD = os.Getenv("NO_FIREWALLD") != ""
41+
3742
func attemptToOpenPorts(config *common.ServerConfig, singBoxConfig *option.Options) {
43+
if noFirewallD {
44+
log.Infof("NO_FIREWALLD is set, not opening ports")
45+
return
46+
}
3847
// check if firewall-cmd exists
3948
if path, _ := exec.LookPath("firewall-cmd"); path == "" {
4049
log.Infof("firewall-cmd not found in $PATH. You may need to open the ports manually.")

0 commit comments

Comments
 (0)