Docker - docker-compose 'version' has no configuration options

I am new to the Docker world, I spent my vacation to find out this docker (however it is much more complicated than Vagrant). So I am using Ubuntu 16.04, I have successfully installed dockers and docker layout.

I read this lesson: Quick Start: docker and rail picker But that doesn't work ... maybe the lesson is wrong.

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 always got this error:

 $ 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, ok, I read a lot of Google results, and it seems like I'm in focus, because I'm using Ubuntu. Unfortunately, the highest version of dockers in Ubuntu is only 1.5.2. (I tried downloading 1.7.1 with curl, but 1.5.2 was 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 I can run rail-based dockers? I cannot install the docker machine because I use ubuntu and the installation will always fail.

However, my PHP docker-compose.yml is fine, because I can run it: light_smile: But this rail tutorial is not very good.

+6
source share
4 answers

The reason is because you deleted the first two lines of the sample tutorial that are followed, and they matter.
Because, looking at the version of docker that you have, you must be on a version of docker-compose above 1.6.x.

To determine this, you can run

 $ docker-compose -v 

In my case, it gets me

docker-compose version 1.7.0, build 0d7bf73

If your version contains 1.7.x or higher, then the information below applies to you.

This should work:

 version: '2' ## <- this line matter and you removed it out the tutorial services: ## <- this line also 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 

There are currently three versions of the Compose file format:

  • Version 1, outdated format. This is indicated by excluding the version key in the root of YAML.
  • Version 2.x. This is indicated in version: "2" or version: "2.1" record in the root of YAML.
  • Version 3.x, the latest and recommended version, designed for cross-compatibility between Compose grand piano mode and Docker Engines. This is indicated in the version: "3" or version: "3.1", etc., Record in the root of YAML.

In addition, here is a small version of docker-compose version / Composer file:

  Compose file format |  Docker engine release
 -------------------- | ----------------------
 3.0;  3.1 |  1.13.0+
 2.1 |  1.12.0+
 2.0 |  1.10.0+
 1.0 |  1.9.1. +

Source: from docker documentation

  • Version 1 is supported by Compose up to 1.6.x. It will be deprecated in a future release of Compose.
  • Version 2 files are supported by Compose 1.6.0+ and require the Docker Engine version 1.10.0 +.
  • Version 2 update that introduces new options available only with Docker Engine version 1.12.0 +
  • An update to version 2.1, which introduces new options available only with the Docker Engine version 1.13.0+. This version also allows you to specify default scale numbers in the service configuration.
  • Designed for cross-compatibility between Compose and Docker Engines roaming mode, version 3 removes a few options and adds a few more.

The docker documentation pages also have practical guidelines for updating the Compose file:

Additional useful docker

+7
source

This shows that the version of your docker-compose has a smaller version. So, if you are on Ubuntu, you can remove docker-compose:

 sudo apt-get purge docker-compose 

Then you can reinstall the latest version with the following command:

 curl -L "https://github.com/docker/compose/releases/download/1.10.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose 

Then

 chmod +x /usr/local/bin/docker-compose 
+3
source

I think the answer from b.enoit.be is correct, but only for completeness (and for the sake of anyone who uses an old version of docker-compose that cannot upgrade yet), it should be possible to do this by changing depends_on to links :

 db: image: postgres web: build: . command: bundle exec rails s -p 3000 -b '0.0.0.0' volumes: - .:/www/html ports: - "3000:3000" links: - db 

This is due to the fact that depends_on was only added to the new version of docker-compose format.

+2
source

In addition to @ b.enoit.be answer :

Ubuntu (and possibly Debian ):

Do not use apt docker-compose package!

If you are using it right now:

 apt purge docker-compose 

It works great with official instructions :

 curl -L "https://github.com/docker/compose/releases/download/1.10.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose; chmod +x /usr/local/bin/docker-compose; docker-compose --version; // docker-compose version 1.10.0, build 4bd6f1a 

You might want to install your official docker-engine first if you also used apt packages for this.

+2
source

All Articles