docker-volume-backup
docker-volume-backup copied to clipboard
docker: command not found
Recently, I noticed that the docker command is not available anymore when using it in POST_BACKUP_COMMAND
:
/root/backup.sh: line 151: docker: command not found
@varhub, @jareware, is this in relation to https://github.com/jareware/docker-volume-backup/pull/53?
Starting and stoping containers, and the exec-pre-backup
and exec-post-backup
commands also do not work anymore.
Oh shoot, I thought I tested that... did you manage to sort it out for yourself @jan-brinkmann?
Hello @jan-brinkmann , sorry by my late reply.
It could be related to #53 because I move docker binary from /usr/bin to /usr/local/bin. This new place is not a feature, only following donator's schema. Therefore, if PATH is different between images or archs, this change unraveled it.
Could you please print the PATH (echo $PATH
) and exec which docker
(1) inside container and (2) inside POST_BACKUP_COMMAND?
On the other hand, I'm not able to reproduce the issue. which docker
:
- amd64 OK
- arm/v7 KO+OK
arm failed to build due to
docker:latest
only supports amd64 and arm64/v8 right now. I switched todocker:stable
to make it work. Sadly, inner and outer versions of docker will not be the same anymore with this change. See: https://github.com/docker-library/docker/issues/357
Finally reproduced....
Testing it through docker-compose exec backup ./backup.sh
(as recommended at Readme) will give following PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
But cron execution chunks the PATH to /usr/bin:/bin
by default. Here is the problem.
Therefore there are 2 options to fixup: a) Move back docker to 'minimal PATH'
-COPY --from=docker:latest /usr/local/bin/docker /usr/local/bin/
+COPY --from=docker:latest /usr/local/bin/docker /usr/bin/
b) make PATH consistent inside and outside cron
-echo "$BACKUP_CRON_EXPRESSION root /root/backup.sh > /proc/1/fd/1 2>&1" > /etc/cron.d/docker-volume-backup
+cat<<EOF>/etc/cron.d/docker-volume-backup
+PATH=$PATH
+$BACKUP_CRON_EXPRESSION root /root/backup.sh > /proc/1/fd/1 2>&1
+EOF
I prefer (b), so a PR is incoming
Works well for my use case.
Thank you, @varhub!
I do get the error again in the current version. It seems like the changes considering the PATH to the entrypoint.sh in the Pull request back then are no longer in the file. Is this by design?