如何将本地卷安装在码头机中 [英] How to mount local volumes in docker machine
问题描述
web:
build:。
命令:./run_web.sh
卷:
- 。:/ app
ports:
- 8000:8000
links:
- db:db
- rabbitmq:rabbit
- redis:redis
运行 docker-compose up -d
一切顺利,直到尝试执行命令并产生错误:
< blockquote>
无法启动容器b58e2dfa503b696417c1c3f49e2714086d4e9999bd71915a53502cb6ef43936d:[8]系统错误:exec:./run_web.sh:stat ./run_web.sh:没有这样的文件或目录
本地卷未装入远程机器。使用webapps代码安装本地卷的建议策略是什么?
也遇到这个问题,它看起来像本地使用docker-machine时,没有安装卷。一个黑客解决方案是
-
获取docker-machine实例的当前工作目录
docker-machine ssh< name> pwd
-
使用命令行工具,如
rsync
将文件夹复制到远程系统rsync -avzhe ssh --progress< name_of_folder> username @ remote_ip:< result _of_pwd_from_1> ;.
默认的pwd是/ root,所以命令以上将是 rsync -avzhe ssh --progress< name_of_folder> username @ remote_ip:/ root
注意:您需要提供远程系统的密码。您可以通过ssh快速创建一个到远程系统并创建密码。
-
更改卷安装指向
docker-compose.yml
文件从。/ app
到/ root / < name_of_folder>:/ app
-
运行
docker-compose up -d
注意当本地进行更改时,不要忘记重新运行 rsync
将更改推送到远程系统。
它不完美,但它的工作原理。问题正在进行 https://github.com/docker/machine/issues/179
其他试图解决这个问题的项目包括 docker-rsync
I am trying to use docker-machine with docker-compose. The file docker-compose.yml has definitions as follows:
web:
build: .
command: ./run_web.sh
volumes:
- .:/app
ports:
- "8000:8000"
links:
- db:db
- rabbitmq:rabbit
- redis:redis
When running docker-compose up -d
all goes well until trying to execute the command and an error is produced:
Cannot start container b58e2dfa503b696417c1c3f49e2714086d4e9999bd71915a53502cb6ef43936d: [8] System error: exec: "./run_web.sh": stat ./run_web.sh: no such file or directory
Local volumes are not mounted to the remote machine. Whats the recommended strategy to mount the local volumes with the webapps' code?
Also ran into this issue and it looks like local volumes are not mounted when using docker-machine. A hack solution is to
get the current working directory of the docker-machine instance
docker-machine ssh <name> pwd
use a command line tool like
rsync
to copy folder to remote systemrsync -avzhe ssh --progress <name_of_folder> username@remote_ip:<result _of_pwd_from_1>.
The default pwd is /root so the command above would be rsync -avzhe ssh --progress <name_of_folder> username@remote_ip:/root
NB: you would need to supply the password for the remote system. You can quickly create one by ssh into the remote system and creating a password.
change the volume mount point in your
docker-compose.yml
file from.:/app
to/root/<name_of_folder>:/app
run
docker-compose up -d
NB when changes are made locally, don't forget to rerun rsync
to push the changes to the remote system.
Its not perfect but it works. An issue is ongoing https://github.com/docker/machine/issues/179
Other project that attempt to solve this include docker-rsync
这篇关于如何将本地卷安装在码头机中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!