I am newbie in the Docker world, I spent my holiday to learn this docker (however it is much harder than Vagrant). So I use Ubuntu 16.04, I installed successfully the docker and docker-compose.
I read this tutorial: Quickstart: Docker Compose and Rails But this is not working... maybe the tutorial is not fine.
I have this docker-compose.yml:
db:
image: postgres
web:
build: .
command: bundle exec rails s -p 3000 -b '0.0.0.0'
volumes:
- .:/www/html
ports:
- "3000:3000"
depends_on:
- db
I got this error always:
$ docker-compose run web rails new . --force --database=postgresql --skip-bundle
ERROR: Validation failed in file './docker-compose.yml', reason(s):
Unsupported config option for 'web' service: 'depends_on'
Mmmm, okay, I read a lot of google result, and it seems I am in a troube, because I use Ubuntu. Unfortunately the highest version number of docker in Ubuntu it is only 1.5.2. (I tried download the 1.7.1 with curl, but 1.5.2 installed automatically.)
$ docker version
Client:
Version: 1.11.1
API version: 1.23
Go version: go1.5.4
Git commit: 5604cbe
Built: Tue Apr 26 23:43:49 2016
OS/Arch: linux/amd64
Server:
Version: 1.11.1
API version: 1.23
Go version: go1.5.4
Git commit: 5604cbe
Built: Tue Apr 26 23:43:49 2016
OS/Arch: linux/amd64
Do you have any ideas, how can I run the rails based docker? I cannot install the docker machine, because I use ubuntu and the installation always will be failed.
However my PHP docker-compose.yml is fine, because I can run it :slight_smile: But this rails tutorial is not good.
This shows that the version of your docker-compose is of a lesser version. So, if you are on Ubuntu, you can uninstall docker-compose:
Then, you can re-install the latest version with these command:
Then,
In addition to @b.enoit.be answer:
Ubuntu (and probably Debian) users:
Do not use apt
docker-compose
package!If you are using it right now:
It works just fine with their official instructions:
You might want to install their official docker-engine too first, if you also used apt packages for this.
The reason is you removed the two first lines of the example tutorial your are following, and they do matter.
Because, looking at the
docker
version you do have you should be on a version ofdocker-compose
higher than 1.6.x.To identify this, you can run
In my case that gets me
If your version there is 1.7.x or higher then the information below definitely apply to you.
This should be working:
Additionally, here is a little
docker-compose
version / Composer file matrix:Source: from docker documentation
On docker documentation pages there are also now practical guides on how to upgrade your Compose file:
Additional useful docker Compose documentation:
I think the answer from b.enoit.be is the right one but just for completeness (and for the sake of anyone using an old version of docker-compose who can't update just yet) it should be possible to make this work by changing
depends_on
tolinks
:This is because
depends_on
has only been added in the new version of the docker-compose format.