[英]docker-machine with rsync
I want to use rsync
within order to synchronize a folder. 我想使用
rsync
来同步文件夹。 docker-machine
allows rsync
with the -d option
. docker-machine
允许使用-d option
进行rsync
。
docker-machine scp -r -d . machine-name:~
This command seems to be working, however, I would like to extend the use of rsync
to: 这个命令似乎有效,但是,我想将
rsync
的使用扩展到:
rsync -rvz --delete --exclude-from=.rsyncignore -e 'docker-machine ssh machine-name' . :
I also tried the following command: 我也尝试了以下命令:
sshpass -p "tcuser" rsync -rvz --delete --exclude-from=.rsyncignore . docker@`docker-machine ip machine-name`:
Both command synchronize everything a first time, however, once everything is synced, I cannot access the VM anymore. 两个命令都是第一次同步所有内容,但是,一旦所有内容同步,我就无法再访问VM了。 If I try to access the VM through
docker-machine ssh machine-name
i receive the response exit status 255
. 如果我尝试通过
docker-machine ssh machine-name
访问VM, docker-machine ssh machine-name
收到响应exit status 255
。 What is happening? 怎么了?
You can find more about here 你可以在这里找到更多相关信息
1.-The Dockerfile 1.- Dockerfile
FROM centos:6
# install rsync
RUN yum update -y
RUN yum -y install rsync xinetd
# configure rsync
ADD ./rsyncd.conf /root/
RUN sed -i 's/disable[[:space:]]*=[[:space:]]*yes/disable = no/g' /etc/xinetd.d/rsync # enable rsync
RUN cp /root/rsyncd.conf /etc/rsyncd.conf
RUN /etc/rc.d/init.d/xinetd start
RUN chkconfig xinetd on
# create the dir that will be synced
RUN mkdir /home/share
# just to keep the container running
CMD /etc/rc.d/init.d/xinetd start && tail -f /dev/null
2.-Build the container within the repository directory. 2. - 在存储库目录中构建容器。
docker build . -t docker-rsync
3.-For start the container and map the rsync server port to a specific host port, like to 3.-启动容器并将rsync服务器端口映射到特定的主机端口,比如
docker run -p 10873:873 docker-rsync
4.-Now we need to sync our share directory and sync any changes again as soon as anything changes. 4.-现在我们需要同步我们的共享目录,并在任何更改后立即再次同步任何更改。 Rsync will only sync changes after an initial sync.
Rsync仅在初始同步后同步更改。
# initial sync
rsync -avP ./share --delete rsync://localhost:10873/example/
# sync on change
fswatch -0 ./share | xargs -0 -n 1 -I {} rsync -avP ./share --delete rsync://localhost:10873/example/
UPGRADE: because docker machines change content and virtual disk need upgrade 升级:因为docker机器改变内容而虚拟磁盘需要升级
first command when changed files in docker containers : 在docker容器中更改文件时的第一个命令:
rsync --ignore-existing --sparse ...
second when docker machine create new files in containers sparse mode ,followed by: 第二,当docker机器在容器稀疏模式下创建新文件时,接着是:
rsync --inplace ...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.