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