Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker compose shows logs despite setting the logging driver to none #9872

Closed
J1635 opened this issue Sep 23, 2022 · 6 comments
Closed

Docker compose shows logs despite setting the logging driver to none #9872

J1635 opened this issue Sep 23, 2022 · 6 comments

Comments

@J1635
Copy link

J1635 commented Sep 23, 2022

Description

Docker compose won't respect the logging driver setting and will show logs despite setting it to none.

Steps to reproduce the issue:

  1. Create the following docker-compose.yaml file
version: "3.9"

services:
  postgres:
    image: postgres
    environment:
      POSTGRES_PASSWORD: password
    logging:
      driver: none
  1. Run docker-compose up or docker compose up

Describe the results you received:
Despite setting the logging driver to none I can see logs printed in the console

[+] Running 1/1
 - Container docker-compose-postgres-1  Recreated                                                                         0.1s 
Attaching to docker-compose-postgres-1
docker-compose-postgres-1  | 
docker-compose-postgres-1  | PostgreSQL Database directory appears to contain a database; Skipping initialization
docker-compose-postgres-1  | 
docker-compose-postgres-1  | 2022-09-23 19:30:43.084 UTC [1] LOG:  starting PostgreSQL 14.5 (Debian 14.5-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
docker-compose-postgres-1  | 2022-09-23 19:30:43.085 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
docker-compose-postgres-1  | 2022-09-23 19:30:43.085 UTC [1] LOG:  listening on IPv6 address "::", port 5432
docker-compose-postgres-1  | 2022-09-23 19:30:43.089 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"docker-compose-postgres-1  | 2022-09-23 19:30:43.095 UTC [26] LOG:  database system was shut down at 2022-09-23 19:10:10 UTC   
docker-compose-postgres-1  | 2022-09-23 19:30:43.101 UTC [1] LOG:  database system is ready to accept connections
Gracefully stopping... (press Ctrl+C again to force)

Describe the results you expected:
I expected no logs to be printed from postgres service.

Additional information you deem important (e.g. issue happens only occasionally):
This issue occurred only after I updated to the latest version of Docker Desktop.

When I run the command with the -d argument and using the docker logs command the none logging driver works as expected and no logs are printed.

Output of docker compose version:

Docker Compose version v2.10.2

Output of docker info:

Client:
 Context:    default
 Debug Mode: false  
 Plugins:
  buildx: Docker Buildx (Docker Inc., v0.9.1)
  compose: Docker Compose (Docker Inc., v2.10.2)
  extension: Manages Docker extensions (Docker Inc., v0.2.9)
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc., 0.6.0)
  scan: Docker Scan (Docker Inc., v0.19.0)

Server:
 Containers: 2
  Running: 0
  Paused: 0
  Stopped: 2
 Images: 2
 Server Version: 20.10.17
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 9cd3357b7fd7218e4aec3eae239db1f68a5a6ec6
 runc version: v1.1.4-0-g5fd4c4d
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 5.10.16.3-microsoft-standard-WSL2
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 12.43GiB
 Name: docker-desktop
 ID: I4I7:M43M:EKMP:IBEX:CXC2:OGGM:LW4D:QAUC:FJAQ:4PC6:BJ5W:PSY6
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 No Proxy: hubproxy.docker.internal
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  hubproxy.docker.internal:5000
  127.0.0.0/8
 Live Restore Enabled: false

WARNING: No blkio throttle.read_bps_device support
WARNING: No blkio throttle.write_bps_device support
WARNING: No blkio throttle.read_iops_device support
WARNING: No blkio throttle.write_iops_device support

Additional environment details:

@nicksieger
Copy link
Member

I believe this is working as expected. Standard output from containers is always shown when you run them in the foreground; setting the logging driver affects how docker logs or docker compose logs works. When I run docker compose logs with your example, I get the expected Error response from daemon: configured logging driver does not support reading.

@J1635
Copy link
Author

J1635 commented Sep 28, 2022

I've a docker compose with 2 services. One is running some tests in .Net and the other spins up a database which is required for the tests to run.

On the previous version of Docker Desktop and using the none driver, I was able to hide database logs and show only the logs from the test service.

@ndeloof
Copy link
Contributor

ndeloof commented Jan 3, 2023

compose v2 uses attach to get running container logs, like docker run does and to align with it. Setting logging-driver has no effect on this.
The related feature to "ignore another service" is addressed by #10137

@ndeloof
Copy link
Contributor

ndeloof commented Jan 3, 2023

Closing this issue as "fixed with a workaround" : while this has been used by many, setting logging driver to none is not intended to be used to mute a service in compose. An explicit flag makes things cleaner and more flexible

@ndeloof ndeloof closed this as completed Jan 3, 2023
@nektro
Copy link

nektro commented Jul 4, 2023

the workaround requires passing a CLI flag every call whereas this issue was about a declarative option that no longer works and also doesn't error upon being used

@ndeloof
Copy link
Contributor

ndeloof commented Jul 6, 2023

@nektro see compose-spec/compose-spec#366

previous option was not a documented feature but a hack relying on docker-compose v1 implementation details, this will make this an explicit feature

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants