【发布时间】:2021-11-29 05:11:26
【问题描述】:
我的容器都在运行,我正在尝试针对它运行 Cypress 测试:
docker-compose.yml:
version: '3.7'
services:
users:
build:
context: ./services/users
dockerfile: Dockerfile
volumes:
- './services/users:/usr/src/app'
expose:
- 5000
environment:
- FLASK_APP=project/__init__.py
- FLASK_ENV=development
- APP_SETTINGS=project.config.DevelopmentConfig
- DATABASE_URL=postgresql://postgres:postgres@users-db:5432/users_dev
- DATABASE_TEST_URL=postgresql://postgres:postgres@users-db:5432/users_test
- SECRET_KEY='hakuna matata'
depends_on:
- users-db
client:
build:
context: ./services/client
dockerfile: Dockerfile
volumes:
- './services/client:/usr/src/app'
- '/usr/src/app/node_modules'
ports:
- 3007:3000
environment:
- CHOKIDAR_USEPOLLING=true
- NODE_ENV=development
- REACT_APP_USERS_SERVICE_URL=${REACT_APP_USERS_SERVICE_URL}
depends_on:
- users
users-db:
build:
context: ./services/users/project/db
dockerfile: Dockerfile
expose:
- 5432
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
nginx:
build:
context: ./services/nginx
dockerfile: Dockerfile
restart: always
ports:
- 80:80
depends_on:
- users
- client
cypress.json:
{
"baseUrl": "http://nginx:80",
"video": false
}
码头工人ps:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
97f91a4b3a81 tdd_nginx "/docker-entrypoint.…" 56 minutes ago Up 56 minutes 0.0.0.0:80->80/tcp, :::80->80/tcp tdd_nginx_1
089cd20326c1 tdd_client "npm start" 56 minutes ago Up 56 minutes 0.0.0.0:3007->3000/tcp, :::3007->3000/tcp tdd_client_1
85dc333cc487 tdd_users "/usr/src/app/entryp…" 56 minutes ago Up 56 minutes 5000/tcp tdd_users_1
696298d0ab2c tdd_users-db "docker-entrypoint.s…" 56 minutes ago Up 56 minutes 5432/tcp tdd_users-db_1
错误输出:
Cypress could not verify that the server set as your `baseUrl` is running:
> http://nginx:80
Your tests likely make requests to this `baseUrl` and these tests will fail if you do
n't boot your server.
Please start this server and then run Cypress again.
给它http://localhost 也没有用。
我正在从容器中运行测试运行器:docker run -it -v $PWD:/e2e -w /e2e cypress/included:3.2.0
环境:
docker 版本 20.10.11,构建 dea9396
赛普拉斯 3.2.0
操作系统:Ubuntu Linux 20.04
欢迎提出任何建议。
【问题讨论】:
-
当所有容器都在运行时,打开浏览器并转到
http://nginx:80或http://localhost:80,它们可以工作吗?