在Windows上的Docker得到“无法findGemfile”

我试图学习使用Windows作为主机操作系统的Docker,使用Docker Hub的 Rails镜像创build一个容器。

我用下面的内容创build了一个Dockerfile和一个空的Gemfile,但是我仍然收到错误“Could not locate Gemfile”。

Dockerfile

FROM rails:4.2.6 

我使用的命令如下(不理解他们实际上做了什么):

 ju.oliveira@br-54 MINGW64 /d/Juliano/ddoc $ docker build -t ddoc . Sending build context to Docker daemon 4.608 kB Step 1 : FROM rails:4.2.6 ---> 3fc52e59c752 Step 2 : MAINTAINER Juliano Nunes ---> Using cache ---> d3ab93260f0f Successfully built d3ab93260f0f SECURITY WARNING: You are building a Docker image from Windows against a non-Windows Docker host. All files and directories added to build context will have '-rwxr-xr-x' permissions. It is recommended to double check and reset permissions for sensitive files and directories. $ docker run --rm -v "$PWD":/usr/src/app -w /usr/src/app ruby:2.1 bundle install Unable to find image 'ruby:2.1' locally 2.1: Pulling from library/ruby fdd5d7827f33: Already exists a3ed95caeb02: Pull complete 0f35d0fe50cc: Already exists 627b6479c8f7: Already exists 67c44324f4e3: Already exists 1429c50af3b7: Already exists f4f9e6a0d68b: Pull complete eada5eb51f5d: Pull complete 19aeb2fc6eae: Pull complete Digest: sha256:efc655def76e69e7443aa0629846c2dd650a953298134a6f35ec32ecee444688 Status: Downloaded newer image for ruby:2.1 Could not locate Gemfile 

所以,我的问题是:

  • 为什么不能findGemfile,如果它在Dockerfile相同的目录中?
  • docker run --rm -v "$PWD":/usr/src/app -w /usr/src/app ruby:2.1 bundle install的命令是什么docker run --rm -v "$PWD":/usr/src/app -w /usr/src/app ruby:2.1 bundle install做什么的?
  • 如何在我的主机文件系统中设置一个文件夹以同步到容器(我想在Windows上使用Docker创buildRails项目的开发环境)?

我不知道这是否有任何区别,但我从通过“Docker快速入门terminal”快捷方式执行的bash运行此命令。 我认为它所做的就是在一个默认的虚拟机上运行这些命令,尽pipe我可以创build一个新的(但我不知道是否应该这样做)。

谢谢你,对于所有这些问题感到抱歉,但是对于我来说Docker似乎很困惑。

您必须将HOST目录挂载到您的HOME目录中(例如c:/ Users / john / *)