mirror of
https://github.com/offen/docker-volume-backup.git
synced 2024-11-14 02:25:49 +01:00
Supporting proxied Docker APIs through DOCKER_HOST (#70)
This commit is contained in:
parent
180438f1fc
commit
58b42b9036
@ -80,7 +80,8 @@ services:
|
|||||||
- data:/backup/my-app-backup:ro
|
- data:/backup/my-app-backup:ro
|
||||||
# Mounting the Docker socket allows the script to stop and restart
|
# Mounting the Docker socket allows the script to stop and restart
|
||||||
# the container during backup. You can omit this if you don't want
|
# 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
|
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||||
# If you mount a local directory or volume to `/archive` a local
|
# If you mount a local directory or volume to `/archive` a local
|
||||||
# copy of the backup will be stored there. You can override the
|
# copy of the backup will be stored there. You can override the
|
||||||
|
@ -90,7 +90,8 @@ func newScript() (*script, error) {
|
|||||||
s.file = timeutil.Strftime(&s.stats.StartTime, s.file)
|
s.file = timeutil.Strftime(&s.stats.StartTime, s.file)
|
||||||
|
|
||||||
_, err := os.Stat("/var/run/docker.sock")
|
_, 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())
|
cli, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("newScript: failed to create docker client")
|
return nil, fmt.Errorf("newScript: failed to create docker client")
|
||||||
|
Loading…
Reference in New Issue
Block a user