Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker: command not found #56

Closed
jan-brinkmann opened this issue Apr 15, 2022 · 7 comments · Fixed by jan-brinkmann/docker-volume-backup#17 · May be fixed by #57
Closed

docker: command not found #56

jan-brinkmann opened this issue Apr 15, 2022 · 7 comments · Fixed by jan-brinkmann/docker-volume-backup#17 · May be fixed by #57

Comments

@jan-brinkmann
Copy link
Contributor

jan-brinkmann commented Apr 15, 2022

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 #53?

@jan-brinkmann
Copy link
Contributor Author

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

@jareware
Copy link
Owner

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

@varhub
Copy link
Contributor

varhub commented Apr 27, 2022

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
Copy link
Contributor

varhub commented Apr 27, 2022

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: docker-library/docker#357

@varhub
Copy link
Contributor

varhub commented Apr 27, 2022

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 added a commit to varhub/docker-volume-backup that referenced this issue Apr 27, 2022
this will ensure that both 'cron based' and 'manual execution' of 
backup.sh will use the same PATH providing consistency during testing

fixes jareware#56
@jan-brinkmann
Copy link
Contributor Author

Works well for my use case.

Thank you, @varhub!

@Tyde
Copy link

Tyde commented Dec 7, 2023

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants