Hi every body,
Maybe this is not a 100% relevant question about docker, but I am having some troubles calling docker cp with a variable.
I am trying to automate some backup calls for my gitlab container. here is my test script:
#!/bin/bash lastbackupfile=$(docker exec -t mygitlab ls /var/opt/gitlab/backups -tr | tail -n1) #lastbackupfile="1513690222_2017_12_19_10.2.5_gitlab_backup.tar" echo $lastbackupfile pathA="mygitlab:/var/opt/gitlab/backups/" path=$pathA$lastbackupfile echo $path docker cp $path /home/aqg
docker exec -t mygitlab ls /var/opt/gitlab/backups -tr | tail -n1 I am fetching the latest created backup from the /var/opt/gitlab/backups frolder.
so, the first echo shows me a correct file name: which is: 1513690222_2017_12_19_10.2.5_gitlab_backup.tar
the last echo shows: mygitlab:/var/opt/gitlab/backups/1513690222_2017_12_19_10.2.5_gitlab_backup.tar
now the last call. docker cp fails with the error:
Error response from daemon: lstat /var/lib/docker/aufs/mnt/48fb0a1f22abc2c8120018b94b5e9687c49471e722c02a6d76907e843f09cff8/var/opt/gitlab/backups/1513690222_2017_12_19_10.2.5_gitlab_backup.tar: no such file or directory
now, wenn I use the same script as above but this time switch the lastbackupfile assignments (just for clarification: lastbackfile is in both cases the same) - then the script work as expected.
in other words, if I make this shorter and just call the following in the terminal:
docker cp mygitlab:/var/opt/gitlab/backups/$(docker exec -t mygitlab ls /var/opt/gitlab/backups -tr | tail -n1) /home/aqg I get tge error as above mentioned.
and of course this works:
docker cp mygitlab:/var/opt/gitlab/backups/1513690222_2017_12_19_10.2.5_gitlab_backup.tar /home/aqg
so, I am guessing, that this is not a problem of the docker, but what am I doing wrong here?
many thanks in advance!