简体   繁体   中英

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

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

View 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.

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...

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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