Docker - docker-compose 'version' 没有任何配置选项
Docker - docker-compose 'version' doesn't have any configuration options
我是Docker世界的新手,我利用假期学习了这个docker(不过比Vagrant难多了)。
所以我使用 Ubuntu 16.04,我成功安装了 docker 和 docker-compose.
我读了这个教程:Quickstart: Docker Compose and Rails
但是这个不行。。。可能是教程写的不好。
我有这个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
我总是遇到这个错误:
$ 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'
嗯,好吧,我看了很多google的结果,看来我很麻烦,因为我用的是Ubuntu。不幸的是Ubuntu中docker的最高版本号只有1.5.2。 (我尝试使用 curl 下载 1.7.1,但自动安装了 1.5.2。)
$ 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
各位有什么想法,我怎样才能运行在rails的基础上docker?
我无法安装docker机器,因为我使用ubuntu并且总是安装失败。
但是我的 PHP docker-compose.yml 很好,因为我可以 运行 :slight_smile: 但是这个 rails 教程不好。
原因是您删除了您所遵循的示例教程的前两行,它们确实很重要。
因为,查看您拥有的 docker
版本,您应该使用高于 1.6.x.
的 docker-compose
版本
要识别这一点,您可以 运行
$ docker-compose -v
以我为例
docker-compose version 1.7.0, build 0d7bf73
如果您的版本是 1.7.x 或更高版本,那么以下信息绝对适用于您。
这应该有效:
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, the legacy format. This is specified by omitting a version
key at the root of the YAML.
- Version 2.x. This is specified with a version: '2' or version: '2.1'
entry at the root of the YAML.
- Version 3.x, the latest and recommended version, designed to be
cross-compatible between Compose and the Docker Engine’s swarm mode.
This is specified with a version: '3' or version: '3.1', etc., entry
at the root of the YAML.
此外,这里有一些 docker-compose
版本/Composer 文件矩阵:
Compose file format
Docker Engine release
3.8
19.03.0+
3.7
18.06.0+
3.6
18.02.0+
3.5
17.12.0+
3.4
17.09.0+
3.3
17.06.0+
3.2
17.04.0+
3.1
1.13.1+
3.0
1.13.0+
2.4
17.12.0+
2.3
17.06.0+
2.2
1.13.0+
2.1
1.12.0+
2.0
1.10.0+
1.0
1.9.1.+
来源:https://docs.docker.com/compose/compose-file/compose-versioning/#compatibility-matrix
- Version 1 is supported by Compose up to 1.6.x. It will be deprecated in a future Compose release.
- Version 2 files are supported by Compose 1.6.0+ and require a Docker Engine of version 1.10.0+.
- An upgrade of version 2 that introduces new parameters only available with Docker Engine version 1.12.0+
- An upgrade of version 2.1 that introduces new parameters only available with Docker Engine version 1.13.0+. This version also allows to specify default scale numbers inside the service’s configuration.
- Designed to be cross-compatible between Compose and the Docker Engine’s swarm mode, version 3 removes several options and adds several more.
在 docker 文档页面上,现在还有关于如何升级 Compose 文件的实用指南:
额外有用的 docker 撰写文档:
我认为 b.enoit.be 的答案是正确的,但只是为了完整性(也是为了任何使用旧版本 docker-compose 的人,他们还不能更新)应该可以通过将 depends_on
更改为 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
这是因为 depends_on
只是在新版本的 docker-compose 格式中添加的。
除了:
Ubuntu(可能还有 Debian)用户:
不要使用apt docker-compose
包!
如果您现在正在使用它:
apt purge docker-compose
它与他们的 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
如果您也为此使用了 apt 包,您可能还想先安装他们的官方 docker-engine。
这说明你的docker-compose版本是低版本。所以,如果你在 Ubuntu,你可以卸载 docker-compose:
sudo apt-get purge docker-compose
然后,您可以使用这些命令re-install最新版本:
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世界的新手,我利用假期学习了这个docker(不过比Vagrant难多了)。 所以我使用 Ubuntu 16.04,我成功安装了 docker 和 docker-compose.
我读了这个教程:Quickstart: Docker Compose and Rails 但是这个不行。。。可能是教程写的不好。
我有这个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
我总是遇到这个错误:
$ 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'
嗯,好吧,我看了很多google的结果,看来我很麻烦,因为我用的是Ubuntu。不幸的是Ubuntu中docker的最高版本号只有1.5.2。 (我尝试使用 curl 下载 1.7.1,但自动安装了 1.5.2。)
$ 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
各位有什么想法,我怎样才能运行在rails的基础上docker? 我无法安装docker机器,因为我使用ubuntu并且总是安装失败。
但是我的 PHP docker-compose.yml 很好,因为我可以 运行 :slight_smile: 但是这个 rails 教程不好。
原因是您删除了您所遵循的示例教程的前两行,它们确实很重要。
因为,查看您拥有的 docker
版本,您应该使用高于 1.6.x.
docker-compose
版本
要识别这一点,您可以 运行
$ docker-compose -v
以我为例
docker-compose version 1.7.0, build 0d7bf73
如果您的版本是 1.7.x 或更高版本,那么以下信息绝对适用于您。
这应该有效:
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, the legacy format. This is specified by omitting a version key at the root of the YAML.
- Version 2.x. This is specified with a version: '2' or version: '2.1' entry at the root of the YAML.
- Version 3.x, the latest and recommended version, designed to be cross-compatible between Compose and the Docker Engine’s swarm mode. This is specified with a version: '3' or version: '3.1', etc., entry at the root of the YAML.
此外,这里有一些 docker-compose
版本/Composer 文件矩阵:
Compose file format | Docker Engine release |
---|---|
3.8 | 19.03.0+ |
3.7 | 18.06.0+ |
3.6 | 18.02.0+ |
3.5 | 17.12.0+ |
3.4 | 17.09.0+ |
3.3 | 17.06.0+ |
3.2 | 17.04.0+ |
3.1 | 1.13.1+ |
3.0 | 1.13.0+ |
2.4 | 17.12.0+ |
2.3 | 17.06.0+ |
2.2 | 1.13.0+ |
2.1 | 1.12.0+ |
2.0 | 1.10.0+ |
1.0 | 1.9.1.+ |
来源:https://docs.docker.com/compose/compose-file/compose-versioning/#compatibility-matrix
- Version 1 is supported by Compose up to 1.6.x. It will be deprecated in a future Compose release.
- Version 2 files are supported by Compose 1.6.0+ and require a Docker Engine of version 1.10.0+.
- An upgrade of version 2 that introduces new parameters only available with Docker Engine version 1.12.0+
- An upgrade of version 2.1 that introduces new parameters only available with Docker Engine version 1.13.0+. This version also allows to specify default scale numbers inside the service’s configuration.
- Designed to be cross-compatible between Compose and the Docker Engine’s swarm mode, version 3 removes several options and adds several more.
在 docker 文档页面上,现在还有关于如何升级 Compose 文件的实用指南:
额外有用的 docker 撰写文档:
我认为 b.enoit.be 的答案是正确的,但只是为了完整性(也是为了任何使用旧版本 docker-compose 的人,他们还不能更新)应该可以通过将 depends_on
更改为 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
这是因为 depends_on
只是在新版本的 docker-compose 格式中添加的。
除了
Ubuntu(可能还有 Debian)用户:
不要使用apt docker-compose
包!
如果您现在正在使用它:
apt purge docker-compose
它与他们的 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
如果您也为此使用了 apt 包,您可能还想先安装他们的官方 docker-engine。
这说明你的docker-compose版本是低版本。所以,如果你在 Ubuntu,你可以卸载 docker-compose:
sudo apt-get purge docker-compose
然后,您可以使用这些命令re-install最新版本:
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