docker-volume-backup icon indicating copy to clipboard operation
docker-volume-backup copied to clipboard

docker: command not found

Open jan-brinkmann opened this issue 2 years ago • 6 comments

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?

jan-brinkmann avatar Apr 15 '22 08:04 jan-brinkmann

Starting and stoping containers, and the exec-pre-backup and exec-post-backup commands also do not work anymore.

jan-brinkmann avatar Apr 15 '22 09:04 jan-brinkmann

Oh shoot, I thought I tested that... did you manage to sort it out for yourself @jan-brinkmann?

jareware avatar Apr 26 '22 10:04 jareware

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?

varhub avatar Apr 27 '22 08:04 varhub

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 to docker: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

varhub avatar Apr 27 '22 09:04 varhub

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

varhub avatar Apr 27 '22 09:04 varhub

Works well for my use case.

Thank you, @varhub!

jan-brinkmann avatar May 01 '22 14:05 jan-brinkmann

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?

Tyde avatar Dec 07 '23 11:12 Tyde