我正在尝试在一个容器中运行应用程序,并在另一个容器中运行玩笑木偶测试。
docker-compose.yml
services:
frontend:
image: my-node
logging:
driver: none
ports:
- "3000:3000"
tests:
depends_on:
- frontend
image: e2e
volumes:
- "./:/usr/src/app/"
command: sh -c "yarn start:dev & ./wait-for-it.sh frontend:3000 -- yarn test:e2e"
Dockerfile
FROM node:latest
RUN apt-get update \
# Install latest chrome dev package, which installs the necessary libs to
# make the bundled version of Chromium that Puppeteer installs work.
&& apt-get install -y wget --no-install-recommends \
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
&& apt-get update \
&& apt-get install -y google-chrome-unstable --no-install-recommends \
&& rm -rf /var/lib/apt/lists/* \
&& wget --quiet https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh -O /usr/sbin/wait-for-it.sh \
&& chmod +x /usr/sbin/wait-for-it.sh
WORKDIR /usr/src/app
COPY package.json yarn.lock ./
RUN yarn install && yarn cache clean
COPY . .
CMD [ "ls"]
因此,如果我正在卷曲frontend:3000,则可以获取响应,但是在测试中,木偶无法连接并给出
Failed to fetch
有人知道怎么了吗? 谢谢!