2016-03-24 39 views
2

我想學習使用Windows作爲主機操作系統的Docker,以使用來自Docker Hub的Rails圖像創建容器。在Windows上的Docker得到「找不到Gemfile」

我已經用下面的內容創建了一個Dockerfile和一個空的Gemfile,但是我仍然收到錯誤「Could not locate Gemfile」。

Dockerfile

FROM rails:4.2.6 

命令我使用的是以下(不理解他們實際上做雖然):

[email protected] 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 

所以,我的問題是:

  • 爲什麼如果它與Dockerfile位於同一目錄下,找不到Gemfile ?
  • 命令docker run --rm -v "$PWD":/usr/src/app -w /usr/src/app ruby:2.1 bundle install是做什麼的?
  • 如何在我的主機文件系統中設置一個文件夾來同步到容器(我試圖在Windows上使用Docker爲Rails項目創建一個開發環境)?

我不知道這是否有任何區別,但我從通過「Docker快速入門終端」快捷方式執行的bash運行此命令。我認爲它所做的只是在默認的VM中運行這些命令,儘管我可以創建一個新的(但我不知道是否應該這樣做)。

謝謝你和所有這些問題抱歉,但是正確的知道Docker對我來說似乎非常困惑。

+1

在Windows上,你不能從一個目錄,如果該目錄是安裝文件**外**您的個人文件夾(通常是C:/ Users/user_name)。 –

回答

1

您必須安裝某主機目錄HOME目錄中(如c:/用戶/ JOHN/*)