【发布时间】:2016-08-03 08:05:48
【问题描述】:
我开发了一个 php symfony 项目并使用 gitlab。 我想在 gitlab 上构建单元测试,为此我使用 gitlab-ci.yml 文件:
image: php:5.6
# Select what we should cache
cache:
paths:
- vendor/
before_script:
# Install git, the php image doesn't have installed
- apt-get update -yqq
- apt-get install git -yqq
# Install mysql driver
- docker-php-ext-install pdo_mysql
# Install composer
- curl -sS https://getcomposer.org/installer | php
# Install all project dependencies
- php composer.phar install
services:
- mysql
variables:
# Configure mysql service (https://hub.docker.com/_/mysql/)
MYSQL_DATABASE: hello_world_test
MYSQL_ROOT_PASSWORD: mysql
# We test PHP5.5 (the default) with MySQL
test:mysql:
script:
- phpunit --configuration phpunit_mysql.xml --coverage-text -c app/
它目前不起作用,因为我的主机名没有在 docker 容器上解析。
我在这里找到了解决方案:How can you make the docker container use the host machine's /etc/hosts file?
我的问题是:我在哪里写 --net=host 选项?
谢谢。
【问题讨论】:
-
看起来这还不可能。这是 gitlab.com 上的一个未解决问题,与您提到的相同问题 gitlab.com/gitlab-org/gitlab-ci-multi-runner/issues/903
-
哪个主机名或什么不工作? (也许还有其他方法可以解决您的问题)
-
实际上我的服务器在防火墙后面,我的 DNS 被重定向到公共 IP。它从外部网络工作正常,但从服务器我应该重定向本地 IP '10.x.x.x' 上的 DNS。你知道我的意思吗?
-
2 年后,
gitlab-ci.yml中仍然无法指定--net=host?