简体   繁体   English

Docker Compose 不暴露网络端口

[英]Docker Compose not exposing network port

I setup this compose file and when I did everything was working as expected, but last week when we tried to actually hand it over to the other dev's to use for development, it was no longer exposing the network and for the life of me I do not know why, plenty of googling has yielded no results.我设置了这个 compose 文件,当我做的一切都按预期工作时,但上周当我们试图将它实际移交给其他开发人员用于开发时,它不再暴露网络,并且在我的生活中我做不知道为什么,大量的谷歌搜索没有产生任何结果。

The network is on bridge, and dev is the only one not working, spinning up prod works fine网络在桥上,只有 dev 不工作,启动 prod 工作正常

  version: '2'
  services:

    dev:
      build:
        context: ./
      volumes:
        - ./:/app
      ports:
        - "8080:8080"
      command: yarn start

    prod:
      build:
        context: ./
      ports:
        - "8080:5000"
      command: node express.js

Here is the associated dockerfile这是关联的 dockerfile

FROM remejuan/node-yarn:8.5.0

# Override the base log level (info).
ENV NPM_CONFIG_LOGLEVEL warn

# Copy all local files into the image.
RUN mkdir -p /app
WORKDIR /app
COPY ./ ./

# Install all dependencies of the current project.
RUN yarn install --pure-lockfile
RUN yarn cache clean

# Install and configure `serve`.
EXPOSE 8080
EXPOSE 5000

I have eliminated the OS as the cause, we have tested it on 2 windows 10 machines running latest CE, same with the mac and my machine is running ubuntu and prod works on all, dev does not, yet in the log I see webpack spinning up, listening on port 8080.我已经排除了操作系统的原因,我们已经在 2 台运行最新 CE 的 Windows 10 机器上对其进行了测试,与 mac 相同,我的机器正在运行 ubuntu 并且 prod 可以正常工作,开发人员没有,但在日志中我看到 webpack 正在旋转up,监听 8080 端口。

Jumping in manually using docker run -ti -p 8080:8080... does not work either.使用 docker run -ti -p 8080:8080... 手动跳转也不起作用。

Grasping at any other idea possible.抓住任何其他可能的想法。

Thanks谢谢

You are exposing your container to same port 8080. That won't work.您将容器暴露在同一个端口 8080 上。那是行不通的。 Because two services are using same port.因为两个服务使用相同的端口。 Try using another port for dev.尝试使用另一个端口进行开发。 You can also set environment and its variables in docker-compose file if you have not specified.如果您没有指定,您也可以在 docker-compose 文件中设置环境及其变量。 Environment should be explicitly specify to detect on which env you are running your app应明确指定环境以检测您正在运行应用程序的环境

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM