Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to print logs when I use command of docker-compose up

I want to print error logs when I run command of docker-compose up

When I run command of docker-compose up, there is no error which can occurs in my web application

But when i run command of docker-compose run web, there is a error message which exactly i wanted.

this is my docker-compose.yml

version: '3'

services:
  db:
    image: postgres
  web:
    build: .
    command: python zeus/manage.py runserver 0.0.0.0:8000
    volumes:
      - .:/zeus_test
    ports:
      - "8000:8000"
    depends_on:
      - db

Is there a way to print error logs when I run command of docker-compose up?


Edit

This is my minimal reproduction

https://github.com/RayKimEX/mydocker-compose

like image 706
RayKim Avatar asked Oct 08 '19 04:10

RayKim


Video Answer


1 Answers

When you run docker-compose run web, the database container doesn't start up together, maybe that's the reason you get error.

But anyway, if you need know what exact errors in servie web containers, I would run below commands to find error out.

docker-compose logs web

Or you only need logs with key word of error

docker-compose logs web |grep -i error

You can add -f to catch latest logs.

    -f, --follow        Follow log output.
like image 130
BMW Avatar answered Sep 30 '22 09:09

BMW