Home > OS >  Open separate terminal logs/output for all services - Docker Compose
Open separate terminal logs/output for all services - Docker Compose

Time:08-05

I am running a web app with docker-compose with a React frontend and FastAPI (Python) backend.

I am trying to get the output for both services on different terminals (they are currently outputting to the same terminal), are there any changes I can make to docker-compose.yml to achieve this?

Docker Compose File:

version: '3.8'

services:
  dockerengine:
    build: ./backend
    volumes:
      - ./backend/src:/src
    ports:
      - 8000:8000
    network_mode: host
    stdin_open: true
    tty: true  
  
  dockerui:
    build: ./frontend
    volumes:
      - ./frontend/src:/src
    ports:
      - 3000:3000
    network_mode: host
    stdin_open: true
    tty: true

Image showing both services outputting to the same terminal: enter image description here

CodePudding user response:

Just open couple of terminals and enter the logs command:

docker-compose logs -f service_name

In your case:

# in a terminal
docker-compose logs -f dockerengine
# in another terminal
docker-compose logs -f dockerui
  • Related