Bitbucketpipe道:将cakephp图像与mysql图像链接在一起

我正在使用Bitbucket piplines。 我有两个图像:cakephp图像和mysql图像。 所以我想指定mysql映像作为服务,所以我可以在我的cakephp映像中使用它。 但问题是:cakephp容器没有看到这个服务。 这里是我使用https://confluence.atlassian.com/bitbucket/test-with-databases-in-bitbucket-pipelines-856697462.html创build的bitbucket-pipelines.yml文件:

image: handkock/cakephptests:1.0 pipelines: default: - step: script: - mysql -u root -e "use db; source /opt/atlassian/pipelines/agent/build/db_dump.sql;" - mysql -u root -e "CREATE DATABASE DB2; use DB2; source /opt/atlassian/pipelines/agent/build/db2.sql;" services: -mysql custom: # Pipelines that are triggered manually test: # The name that is displayed in the list in the Bitbucket Cloud GUI - step: script: - echo "Manual triggers are awesome!" deployment-to-prod: # Another display name - step: script: - echo "Manual triggers for deployments are awesome!" branches: # Pipelines that run automatically on a commit to a branch dockertest: - step: script: - apt-get update //some steps which requires connection to DB and DB2 //here is the place where I need my Mysql connection. definitions: mysql: image: mysql environment: MYSQL_DATABASE: 'db' MYSQL_ROOT_PASSWORD: '' 

但是当我尝试运行unit testing(这需要与数据库连接)我得到Error: Database connection "Mysql" is missing, or could not be created. 我的问题是:1)我在做什么不对? 2)我应该在哪里创build我的数据库,所以我可以从我的dockertest分支(它在.yml文件中描述)访问它。