Docker on Windows getting “Could not locate Gemfile”

I’m trying to learn Docker using Windows as the host OS to create a container using Rails image from Docker Hub.

I’ve created a Dockerfile with the content below and an empty Gemfile, however I’m still getting the error “Could not locate Gemfile”.


FROM rails:4.2.6

The commands I used are the following (not understanding what they actually do though):

$ 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

So, my questions are:

  • Why it can’t find the Gemfile if it’s in the same directory as the Dockerfile?

  • What does the command docker run --rm -v “$PWD”:/usr/src/app -w /usr/src/app ruby:2.1 bundle install do?

  • How do I set a folder in my host file system to be synced to the container (I’m trying to create a development environment for Rails projects using Docker on Windows)?

I don’t know if this makes any difference, but I’m running this command from the bash executed via “Docker Quickstart Terminal” shortcut. I think all it does is run these commands in a default VM, though I could create a new one (but I don’t know if I should do this).

Thank you and sorry for all these questions, but right know Docker seems very confusing for me.