diff --git a/README.md b/README.md index 1a98149..800c373 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,8 @@ services: - data:/backup/my-app-backup:ro # Mounting the Docker socket allows the script to stop and restart # the container during backup. You can omit this if you don't want - # to stop the container + # to stop the container. In case you need to proxy the socket, you can + # also provide a location by setting `DOCKER_HOST` in the container - /var/run/docker.sock:/var/run/docker.sock:ro # If you mount a local directory or volume to `/archive` a local # copy of the backup will be stored there. You can override the diff --git a/cmd/backup/script.go b/cmd/backup/script.go index d82be94..58e6d64 100644 --- a/cmd/backup/script.go +++ b/cmd/backup/script.go @@ -90,7 +90,8 @@ func newScript() (*script, error) { s.file = timeutil.Strftime(&s.stats.StartTime, s.file) _, err := os.Stat("/var/run/docker.sock") - if !os.IsNotExist(err) { + _, dockerHostSet := os.LookupEnv("DOCKER_HOST") + if !os.IsNotExist(err) || dockerHostSet { cli, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation()) if err != nil { return nil, fmt.Errorf("newScript: failed to create docker client")