• [x] I have tried with the latest version of Docker Desktop
  • [x] I have tried disabling enabled experimental features
  • [x] I have uploaded Diagnostics
  • Diagnostics ID: 6170E5C2-D08F-4A43-A287-05574F05EBFB/20230124100548

Expected behavior

When running development container (using compose configuration), stdout produced by the container is visible both in container logs (docker logs '<container-id>') and in docker compose logs.

This works in version 4.10.1 and is in one way or another broken in all the later minor versions.

Actual behavior

Development container doesn't output stdout into docker compose logs but it does output to it's own container log. This behavior starts in version 4.13.0 and is present in all later minor releases which was concluded by testing each minor release from v4.10.0 to v4.16.0. I could not test versions 4.11.0 and 4.12.0 due to some other dev container bug that was introduced in version 4.11.0 and later resolved in version 4.13.0.

In addition to described behavior, version 4.13.0 introduces another bug, that is not present in version 4.10.1. When running any type of Docker or Docker compose command, the execution of command fails due to unsuccessful connection to the Docker deamon.

➜ docker compose build
[+] Building 0.0s (0/0)
no valid drivers found: Cannot connect to the Docker daemon at tcp://localhost:2375. Is the docker daemon running?

This can be temporarly solved by exporting DOCKER_HOST environment variable, as seen below. Again, this step was not needed in the previous versions up to v4.13.0 and may be connected to the aforementioned dev container bug.

➜ export DOCKER_HOST=unix:///var/run/docker.sock

# build command now executes successfully
➜ docker compose build
[+] Building 1.2s (13/13) FINISHED
 => [internal] load build definition from Dockerfile
 => => transferring dockerfile: 32B
 => [internal] load .dockerignore
 => => transferring context: 2B

Information

  • macOS Version: tested both on MacOS Monterey (version 12.6) and MacOS Ventura 13.0
  • Intel chip or Apple chip: tested both on Apple M1 and Apple M1 Pro chips
  • Docker Desktop Version: anything above v4.13.0 but diagnostics and logs in this issue were produced using version v4.16.2

Output of /Applications/Docker.app/Contents/MacOS/com.docker.diagnose check

Starting diagnostics

[PASS] DD0027: is there available disk space on the host?
[PASS] DD0028: is there available VM disk space?
[PASS] DD0018: does the host support virtualization?
[PASS] DD0001: is the application running?
[PASS] DD0017: can a VM be started?
[PASS] DD0016: is the LinuxKit VM running?
[PASS] DD0011: are the LinuxKit services running?
[PASS] DD0004: is the Docker engine running?
[PASS] DD0015: are the binary symlinks installed?
[PASS] DD0031: does the Docker API work?
[PASS] DD0013: is the $PATH ok?
[PASS] DD0003: is the Docker CLI working?
[PASS] DD0038: is the connection to Docker working?
[PASS] DD0014: are the backend processes running?
[PASS] DD0007: is the backend responding?
[PASS] DD0008: is the native API responding?
[PASS] DD0009: is the vpnkit API responding?
[PASS] DD0010: is the Docker API proxy responding?
[SKIP] DD0030: is the image access management authorized?
[PASS] DD0033: does the host have Internet access?
[PASS] DD0018: does the host support virtualization?
[PASS] DD0001: is the application running?
[PASS] DD0017: can a VM be started?
[PASS] DD0016: is the LinuxKit VM running?
[PASS] DD0011: are the LinuxKit services running?
[PASS] DD0004: is the Docker engine running?
[PASS] DD0015: are the binary symlinks installed?
[PASS] DD0031: does the Docker API work?
[PASS] DD0032: do Docker networks overlap with host IPs?
No fatal errors detected.

Steps to reproduce the behavior

  1. Configure any set of compose services and configure docker development container configuration for one of configured services. In this example Django app is used.
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/python
{
    "name": "my-dev-container",
    "dockerComposeFile": [
        "docker-compose.yml"
    ],
    "service": "my-app-django",
    "runServices": [
        "my-app-django"
    ],
    "workspaceFolder": "/var/www",
    "remoteUser": "www",
    "overrideCommand": false,
    "shutdownAction": "stopCompose",

    // Determines settings and extensions to use in the container
    "customizations": {
        "vscode": {
            "settings": {
                "editor.tabSize": 4,
                "terminal.integrated.fontSize": 14
            },
            "extensions": [
                "ms-python.python",
                "ms-python.vscode-pylance"
            ]
        }
    },

    // Execute a specific set of startup commands at different points in the container's lifecycle, redirect output to both stdout and compose logs
    "onCreateCommand": "python manage.py migrate | tee -a /proc/1/fd/1",
    "postCreateCommand": "pip3 install autopep8 | tee -a /proc/1/fd/1 && pip3 install pycodestyle | tee -a /proc/1/fd/1"
}

  1. Run dev container using Rebuild and Reopen command of VS Code Dev Container plugin.
  2. At this point, if container outputs anything to stdout, the output is visible in it's own container log but not in the compose log. This can be tested by intentionally sending something to /proc/1/fd/1 and seeing if it appears in both logs.

This is executed inside the dev container's shell:

[email protected]:/var/www$ echo "Hello World" >> /proc/1/fd/1

This is the output of my-app-django log file:

➜ docker logs -f my-app-django
Container started
Performing system checks...

System check identified no issues (0 silenced).
January 24, 2023 - 10:59:30
Django version 4.1.3, using settings 'core.settings'
Starting development server at http://0.0.0.0:80/
Quit the server with CONTROL-C.

Operations to perform:
  Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
  No migrations to apply.

Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: autopep8 in /usr/local/lib/python3.10/site-packages (2.0.0)
Requirement already satisfied: pycodestyle>=2.9.1 in /usr/local/lib/python3.10/site-packages (from autopep8) (2.10.0)
Requirement already satisfied: tomli in /usr/local/lib/python3.10/site-packages (from autopep8) (2.0.1)
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pycodestyle in /usr/local/lib/python3.10/site-packages (2.10.0)

Hello World

This is the output of docker compose logs command (actual behavior):

➜ docker compose logs --follow
my-app-webserver   | 2023/01/24 10:58:16 [notice] 1#1: start worker process 36
my-app-webserver   | 2023/01/24 10:58:16 [notice] 1#1: start worker process 37
my-app-webserver   | 2023/01/24 10:58:16 [notice] 1#1: start worker process 38
my-app-webserver   | 2023/01/24 10:58:16 [notice] 1#1: start worker process 39
my-app-redis       | 1:M 24 Jan 10:58:16.566 # Server started, Redis version 3.2.12
my-app-redis       | 1:M 24 Jan 10:58:16.566 * The server is now ready to accept connections on port 6379

This is the output of docker compose logs command (expected behavior) using Docker v4.10.1:

my-app-webserver   | 2023/01/24 10:58:16 [notice] 1#1: start worker process 36
my-app-webserver   | 2023/01/24 10:58:16 [notice] 1#1: start worker process 37
my-app-webserver   | 2023/01/24 10:58:16 [notice] 1#1: start worker process 38
my-app-webserver   | 2023/01/24 10:58:16 [notice] 1#1: start worker process 39
my-app-redis       | 1:M 24 Jan 10:58:16.566 # Server started, Redis version 3.2.12
my-app-redis       | 1:M 24 Jan 10:58:16.566 * The server is now ready to accept connections on port 6379
my-app-django      | Container started
my-app-django      | Performing system checks...
my-app-django      |
my-app-django      | System check identified no issues (0 silenced).
my-app-django      | January 24, 2023 - 10:59:30
my-app-django      | Django version 4.1.3, using settings 'core.settings'
my-app-django      | Starting development server at http://0.0.0.0:80/
my-app-django      |
my-app-django      | Operations to perform:
my-app-django      |   Apply all migrations: admin, auth, contenttypes, sessions
my-app-django      | Running migrations:
my-app-django      |   No migrations to apply.
my-app-django      |
my-app-django      | Defaulting to user installation because normal site-packages is not writeable
my-app-django      | Requirement already satisfied: autopep8 in /usr/local/lib/python3.10/site-packages (2.0.0)
my-app-django      | Requirement already satisfied: pycodestyle>=2.9.1 in /usr/local/lib/python3.10/site-packages (from autopep8) (2.10.0)
my-app-django      | Requirement already satisfied: tomli in /usr/local/lib/python3.10/site-packages (from autopep8) (2.0.1)
my-app-django      | Defaulting to user installation because normal site-packages is not writeable
my-app-django      | Requirement already satisfied: pycodestyle in /usr/local/lib/python3.10/site-packages (2.10.0)
0
© 2022 pullanswer.com - All rights reserved.