Certain container doesn't show logs in console spew, just in Docker Desktop

I have a container which is only showing logs in the Docker Desktop application. I have 6 services in the compose file, and 5 of them show logs in my terminal as expected when launched with docker-compose -p my_app up. But one of them (api) doesn’t show the logs in the terminal, and I can only see them by using Docker Desktop.

This used to work, I don’t know what changed. How can I ensure that all the logging appears in the console? Software versions:

macOS: 12.3
Docker: 20.10.13, build a224086
Docker Compose: version v2.3.3

Here’s an excerpt of the compose file, showing the service that’s not working (api) and two others that ARE sending combined output to the console as expected.:

version: "3.9"

services:
  api:
    # Relative to the directory this docker-compose file is in
    # Vars not available during build https://docs.docker.com/compose/compose-file/compose-file-v3/#env_file
    env_file: ../.env

    build:
      context: ..
      dockerfile: ./docker/Dockerfile
    image: api
    deploy:
      restart_policy:
        condition: on-failure
        delay: 3s
        max_attempts: 5
        window: 60s
    depends_on:
      - db
      - redis
    environment: &api_env
      # Set the database variables, which may be different in the container than on the host
      PG_ENDPOINT: db
      PG_PORT: 5432
      PG_DATABASE: my_db
      PG_USERNAME: test
      PG_PASSWORD: test
      REDIS_URL: redis://redis
    networks:
      - flasknetwork
    ports:
      - ${API_PORT:-5050}:5000
    restart: always
    entrypoint: ./docker/entrypoint.dev.sh

    # To enable pdb within Docker:
    # https://hackernoon.com/debugging-using-pdb-in-dockerized-environment-i21n2863
    stdin_open: true
    tty: true

    # Bind the project directory into the container so changes are reflected by Flask
    volumes:
      - ..:/home/appuser/my_app

    logging:
      options:
        max-size: "10m"
        max-file: "3"

  db:
    image: postgis/postgis:12-master
    environment:
      POSTGRES_HOST_AUTH_METHOD: trust
      POSTGRES_USER: test
      POSTGRES_PASSWORD: test
      POSTGRES_DB: my_db
    restart: always
    networks:
      - flasknetwork
    ports:
      - 5432:5432
    volumes:
      - postgres-data:/var/lib/postgresql/data
    logging:
      options:
        max-size: "10m"
        max-file: "3"

  redis:
    image: redis:latest
    ports:
      - 6379:6379
    networks:
      - flasknetwork

And here’s the beginning of the spew, with the api container output missing:

 ⠿ Container my_app-redis-1            Created
 ⠿ Container my_app-db-1               Created
 ⠿ Container my_app-worker-1           Created
 ⠿ Container my_app-redis-commander-1  Created
 ⠿ Container my_app-api-1              Created
Attaching to my_app-api-1, my_app-db-1, my_app-redis-1, my_app-redis-commander-1, my_app-worker-1
my_app-redis-commander-1  | Creating custom redis-commander config '/redis-commander/config/local-production.json'.
my_app-redis-1            | 1:C 05 Apr 2022 01:32:11.069 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
my_app-redis-1            | 1:C 05 Apr 2022 01:32:11.069 # Redis version=6.2.6, bits=64, commit=00000000, modified=0, pid=1, just started
my_app-redis-1            | 1:C 05 Apr 2022 01:32:11.069 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
my_app-redis-1            | 1:M 05 Apr 2022 01:32:11.069 * monotonic clock: POSIX clock_gettime
my_app-redis-1            | 1:M 05 Apr 2022 01:32:11.070 * Running mode=standalone, port=6379.
my_app-redis-1            | 1:M 05 Apr 2022 01:32:11.070 # Server initialized
my_app-redis-1            | 1:M 05 Apr 2022 01:32:11.072 * Loading RDB produced by version 6.2.6
my_app-redis-1            | 1:M 05 Apr 2022 01:32:11.072 * RDB age 331438 seconds
my_app-redis-1            | 1:M 05 Apr 2022 01:32:11.072 * RDB memory usage when created 0.80 Mb
my_app-redis-1            | 1:M 05 Apr 2022 01:32:11.072 # Done loading RDB, keys loaded: 0, keys expired: 2.
my_app-redis-1            | 1:M 05 Apr 2022 01:32:11.072 * DB loaded from disk: 0.000 seconds
my_app-redis-1            | 1:M 05 Apr 2022 01:32:11.072 * Ready to accept connections
my_app-redis-commander-1  | Parsing 1 REDIS_HOSTS into custom redis-commander config '/redis-commander/config/local-production.json'.
my_app-db-1               |
my_app-db-1               | PostgreSQL Database directory appears to contain a database; Skipping initialization
my_app-db-1               |
# ETC ETC ETC

Can you read the logs with docker logs without docker compose? You should see the same output from the terminal as you see on the GUI. Try to find out if it is Docker Compose or the Docker CLI what shows you empty log

Using docker logs my_app-api-1 shows the same output as what’s shown in Docker Desktop. There’s definitely logging there, it just isn’t being shown by docker-compose like it used to be. Multiple members of my team are seeing the same behavior.

Any other ideas?

Is the log empty even when you filter to only the api service?

dockder-compose logs api

The log is not empty in that case, but I want the logs from all the services to show up in a single place like they used to.

It seems the issue is that Docker Compose has changed the way tty: true behaves. There’s more in this docker-compose issue on Github, and it also looks like 2.4.1 has fixed the problem. Hope that version will make its way into Docker Desktop soon!

Obviously, but this is how you find the cause of an error step by step checking what works and what doesn’t

Excellent… Let’s hope they will slow down and focus on stability soon. Although, I could not reproduce the issue.

You don’t have to wait. Just download the release file from GitHub: Releases · docker/compose · GitHub.

Thanks for the suggestion. Will installing my own version interfere with the updates installed by Docker Desktop?

I don’t think so, but you can save the file somewhere else and append its path to the PATH variable.