[英]How to output progress of rsync by running it through a script in docker-compose?
I'm running rsync through a script, but I'm not getting the progress bar.我正在通过脚本运行 rsync,但没有看到进度条。 It works fine when I run it directly, but when I run the script, I only get the echoes.
当我直接运行它时它工作正常,但是当我运行脚本时,我只得到回声。
In my docker-compose.yml
:在我
docker-compose.yml
:
command: /home/node/build-dir/command.sh
tty : true # Show output with syntax highlighting support.
#!/bin/ash
# First check if the directory is empty, as it is when it is mounted for the first time.
if [ -z "$(ls -A /home/node/work-dir/node_modules)" ]
then
echo 'Beginning to copy node_modules folder...'
# Recursively copy all files of build directory to that of the working directory.
rsync -ah --info=progress2 /home/node/build-dir/node_modules /home/node/work-dir/node_modules
echo 'Finished copying node_modules folder...'
else
echo 'The folder "node_modules" already exists; skipping copying.'
fi
# Run npm start command to start development.
exec npm start
I want it to show the progress and then stop when it finishes, finishing the script run.我希望它显示进度,然后在完成时停止,完成脚本运行。 I want it to be as if when I run it directly through the shell using
docker exec -it my_app ash
and then running the following:我希望它就像我使用
docker exec -it my_app ash
直接通过 shell 运行它,然后运行以下命令一样:
rsync -ah --info=progress2 /home/node/build-dir/node_modules /home/node/work-dir/node_modules
So far, I get nothing, as in it acts the same as cp.到目前为止,我一无所获,因为它的作用与 cp 相同。 I get the two echos "Beginning to copy..." and "Finished copying..." and that's it.
我得到两个回声“开始复制......”和“完成复制......”,就是这样。 Where's the progress?
进展在哪里?
My only assumption is that I've done something wrong with my docker-compose.yml
file.我唯一的假设是我
docker-compose.yml
文件有问题。
I was using docker-compose up...
while I was supposed to use docker-compose run...
.我正在使用
docker-compose up...
而我应该使用docker-compose run...
。
Source for finding my answer: Interactive shell using Docker Compose .寻找答案的来源: Interactive shell using Docker Compose 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.