Unable to complete "Quickstart: Compose and Rails" with Docker for Windows

Installation and “getting started” worked fine for me. But, going through the Quickstart: Compose and Rails document doesn’t seem to work. When following along with the document, I get to this point in the “Build the project” section…

$ docker-compose run web rails new . --force --database=postgresql --skip-bundle

When I run this, I get an error…

C:\docker\demorails>docker-compose run web rails new . --force --database=postgresql --skip-bundle
ERROR: Interactive mode is not yet supported on Windows.
Please pass the -d flag when using docker-compose run.

When I run this, the operation completes. But, I don’t see the rails app get created in the current directory.

C:\docker\demorails>docker-compose run -d web rails new . --force --database=postgresql --skip-bundle
Pulling db (postgres:latest)…
latest: Pulling from library/postgres
51f5c6a04d83: Already exists
a3ed95caeb02: Already exists
4a40f149a638: Already exists
7e8f4bc7ac43: Already exists
f2a70e1bea0a: Already exists
6d6ccf3c012c: Already exists
4b0c5c71fa5d: Already exists
25bfb55e9c4d: Already exists
8a89d2b357b5: Already exists
192657c53414: Already exists
bdfd3fbe2d25: Already exists
055e85b433f4: Already exists
Digest: sha256:c8be18edd1da7013c02c4ce3e2cadb22051e7b912975746ebff95bd02130e2f9
Status: Downloaded newer image for postgres:latest
Starting demorails_db_1
Building web
Step 1 : FROM ruby:2.2.0
—> bc5beaf30723
Step 2 : RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs
—> Running in 1c8d15a55865
Reading package lists…
Building dependency tree…
Reading state information…
build-essential is already the newest version.
The following package was automatically installed and is no longer required:
Use ‘apt-get autoremove’ to remove it.
The following extra packages will be installed:
libc-ares2 libpq5 libv8-3.14.5
Suggested packages:
The following NEW packages will be installed:
libc-ares2 libv8-3.14.5 nodejs
The following packages will be upgraded:
libpq-dev libpq5
2 upgraded, 3 newly installed, 0 to remove and 195 not upgraded.
Need to get 2280 kB of archives.
After this operation, 7502 kB of additional disk space will be used.
Get:1 http://security.debian.org/ jessie/updates/main libpq-dev amd64 9.4.6-0+deb8u1 [163 kB]
Get:2 http://security.debian.org/ jessie/updates/main libpq5 amd64 9.4.6-0+deb8u1 [123 kB]
Get:3 debian/ jessie/main libc-ares2 amd64 1.10.0-2 [76.7 kB]
Get:4 debian/ jessie/main libv8-3.14.5 amd64 [1269 kB]
Get:5 debian/ jessie/main nodejs amd64 0.10.29~dfsg-2 [648 kB]
debconf: delaying package configuration, since apt-utils is not installed
Fetched 2280 kB in 2s (1087 kB/s)
(Reading database … 27879 files and directories currently installed.)
Preparing to unpack …/libpq-dev_9.4.6-0+deb8u1_amd64.deb …
Unpacking libpq-dev (9.4.6-0+deb8u1) over (9.4.0-1) …
Preparing to unpack …/libpq5_9.4.6-0+deb8u1_amd64.deb …
Unpacking libpq5:amd64 (9.4.6-0+deb8u1) over (9.4.0-1) …
Selecting previously unselected package libc-ares2:amd64.
Preparing to unpack …/libc-ares2_1.10.0-2_amd64.deb …
Unpacking libc-ares2:amd64 (1.10.0-2) …
Selecting previously unselected package libv8-3.14.5.
Preparing to unpack …/libv8-3.14.5_3.14.5.8-8.1_amd64.deb …
Unpacking libv8-3.14.5 ( …
Selecting previously unselected package nodejs.
Preparing to unpack …/nodejs_0.10.29~dfsg-2_amd64.deb …
Unpacking nodejs (0.10.29~dfsg-2) …
Setting up libpq5:amd64 (9.4.6-0+deb8u1) …
Setting up libpq-dev (9.4.6-0+deb8u1) …
Setting up libc-ares2:amd64 (1.10.0-2) …
Setting up libv8-3.14.5 ( …
Setting up nodejs (0.10.29~dfsg-2) …
update-alternatives: using /usr/bin/nodejs to provide /usr/bin/js (js) in auto mode
Processing triggers for libc-bin (2.19-13) …
—> 92522256184a
Removing intermediate container 1c8d15a55865
Step 3 : RUN mkdir /myapp
—> Running in b3f4a8f52ceb
—> 42b8878d51af
Removing intermediate container b3f4a8f52ceb
Step 4 : WORKDIR /myapp
—> Running in ce0cc9a3c228
—> 296a94f89da0
Removing intermediate container ce0cc9a3c228
Step 5 : ADD Gemfile /myapp/Gemfile
—> 7dd3890ab9e4
Removing intermediate container 4cc62075cdde
Step 6 : ADD Gemfile.lock /myapp/Gemfile.lock
—> a2ddabe7b3e7
Removing intermediate container 483b7cc992d0
Step 7 : RUN bundle install
—> Running in 465018cdcb0a
Don’t run Bundler as root. Bundler can ask for sudo if it is needed, and
installing your bundle as root will break this application for all non-root
users on this machine.
Fetching gem metadata from rubygems.org/
Fetching additional metadata from rubygems.org/
Resolving dependencies…
Installing rake 11.1.2
Installing i18n 0.7.0
Installing json 1.8.3
Installing minitest 5.9.0
Installing thread_safe 0.3.5
Installing tzinfo 1.2.2
Installing activesupport 4.2.0
Installing builder 3.2.2
Installing erubis 2.7.0
Installing mini_portile2 2.0.0
Installing nokogiri
Installing rails-deprecated_sanitizer 1.0.3
Installing rails-dom-testing 1.0.7
Installing loofah 2.0.3
Installing rails-html-sanitizer 1.0.3
Installing actionview 4.2.0
Installing rack 1.6.4
Installing rack-test 0.6.3
Installing actionpack 4.2.0
Installing globalid 0.3.6
Installing activejob 4.2.0
Installing mime-types-data 3.2016.0521
Installing mime-types 3.1
Installing mail 2.6.4
Installing actionmailer 4.2.0
Installing activemodel 4.2.0
Installing arel 6.0.3
Installing activerecord 4.2.0
Using bundler 1.7.12
Installing concurrent-ruby 1.0.2
Installing thor 0.19.1
Installing railties 4.2.0
Installing sprockets 3.6.0
Installing sprockets-rails 3.0.4
Installing rails 4.2.0
Your bundle is complete!
It was installed into /usr/local/bundle
—> 98f83d9d3895
Removing intermediate container 465018cdcb0a
Step 8 : ADD . /myapp
—> 459c1c8fba61
Removing intermediate container 3b37c6fbe070
Successfully built 459c1c8fba61
WARNING: Image for service web was built because it did not already exist. To rebuild this image you must use docker-compose build or docker-compose up --build.

C:\docker\demorails>docker ps
7fe0cdc3aeb1 postgres “/docker-entrypoint.s” 2 hours ago Up 2 minutes 5432/tcp demorails_db_1

Volume in drive C is Windows
Volume Serial Number is 0AE0-C2BA

Directory of C:\docker\demorails

05/25/2016 03:39 PM .
05/25/2016 03:39 PM …
05/25/2016 03:25 PM 224 docker-compose.yml
05/25/2016 03:20 PM 230 Dockerfile
05/25/2016 03:23 PM 53 Gemfile
05/25/2016 03:22 PM 8 Gemfile.lock
4 File(s) 515 bytes
2 Dir(s) 142,597,185,536 bytes free

Please advise.

1 Like

I have the same problem. Would be nice to have a solution for this.

You need to use the Shared Drives settings pane in Docker for Windows to enable file sharing to fix this issue. This really should be in the tutorial IMHO.

This is a known limitation with docker-compose on some shells on Windows (like powershell) https://github.com/docker/compose/issues/3194

We run the rails application in our tests using git-bash and it works from there

Anyone else who runs into this problem on windows 10 . Check your line endings. windows by default uses “CRLF” line endings. after converting to “LF” this ran fine and created the app and directories. You may then run into a DB conneciton issue after though…windows man…DB issue

One option to resolve the line ending issue is to use a file named ‘.gitattributes’ (note the dot at the beginning of the file name) at the root of the repository with the following content:

# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto eol=lf

# Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary

I frequently work in teams were people have Windows, MaOS or Linux and this file is a big help in those cases.