简体   繁体   English

Docker-组合起始容器两次,运行命令两次并具有相同的内容

[英]Docker-compose starting containers twice, running command twice and have same content

I get the server container twice, and the view container has the server's content. 我得到服务器容器两次,视图容器有服务器的内容。 I have no idea what is going on... 我不知道发生了什么......

docker-compose 泊坞窗,撰写

version: '3'

services:
    server: 
        build: ./server
    view:
        build: ./view
        ports: 8080:80

Server Dockerfile 服务器Dockerfile

FROM node
WORKDIR /usr/src/app
COPY package.json .
COPY package.json package-lock.json ./
RUN npm install
COPY . .
CMD [ "npm", "start" ]

View Dockerfile 查看Dockerfile

FROM nginx
COPY ./src /usr/share/nginx/html

The images build fine. 图像构建正常。

在此输入图像描述

Is this normal? 这是正常的吗? Looks like node is starting twice? 看起来节点开始两次?

在此输入图像描述

Both containers have the same content. 两个容器都具有相同的内容。 This doesn't look right. 这看起来不对。

在此输入图像描述

Any help is greatly appreciated. 任何帮助是极大的赞赏。

When you do docker-compose up it will start streaming all logs from all containers that were brought up. 当您进行docker-compose up ,它将开始从所有启动的容器docker-compose up传输所有日志。

This simply looks like server_1 output some stuff, and then view_1 output some stuff, and then server_1 output some more stuff, etc... 这看起来就像server_1输出一些东西,然后view_1输出一些东西,然后server_1输出更多东西等等......

If you want to see the logs for an individual service, you can run docker-compose logs server or docker-compose logs view , and get the logs for a specific service only. 如果要查看单个服务的日志,可以运行docker-compose logs serverdocker-compose logs view ,并仅获取特定服务的日志。

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

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