【发布时间】:2017-08-13 21:51:18
【问题描述】:
我有一个关于 Travis 的 Rails 存储库。它有一个 docker-compose.yml 文件:
postgres:
image: postgres
ports:
- "5433:5432"
environment:
- POSTGRES_USER=calories
- POSTGRES_PASSWORD=secretpassword
(我不得不使用 5433 作为主机端口,因为 5432 给了我一个错误:Error starting userland proxy: listen tcp 0.0.0.0:5432: bind: address already in use)
还有一个 travis.yml:
sudo: required
services:
- docker
language: ruby
cache: bundler
before_install:
# Install docker-compose
- curl -L https://github.com/docker/compose/releases/download/1.4.0/docker-compose-`uname -s`-`uname -m` > docker-compose
- chmod +x docker-compose
- sudo mv docker-compose /usr/local/bin
# TODO: Remove this temporary fix when it's safe to:
# https://github.com/travis-ci/travis-ci/issues/4778
- sudo iptables -N DOCKER || true
- sleep 10
- docker-compose up -d
before_script:
- bundle exec rake db:setup
script:
- bundle exec rspec spec
after_script:
- docker-compose stop
- docker-compose rm -f
我正在尝试找出在我的 database.yml 中放入什么,以便我的测试可以在 Travis CI 上运行。在我的其他环境中,我可以这样做:
adapter: postgresql
encoding: unicode
host: <%= `docker-machine ip default` %>
port: 5433
username: calories
password: secretpassword
# For details on connection pooling, see rails configuration guide
# http://guides.rubyonrails.org/configuring.html#database-pooling
pool: 5
但不幸的是,这在 Travis 上不起作用,因为 Travis 上没有 docker-machine。我收到一个错误:docker-machine: command not found
如何在 Travis 上获取 Docker 主机的 IP?
【问题讨论】:
-
您是否尝试在
script的.travis.yml文件中添加- docker ps?它应该显示所有正在运行的容器;)
标签: ruby-on-rails docker chef-infra travis-ci