docker / docker/docker-py

Stuck with run() when with journald logging backend

Open
#2,367 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
7.2k
Forks
1.7k
Avg merge
13d 8h
Merged PRs (30d)
2

Description

environment overview:

  • ubuntu 18.04.2
  • docker version: 18.09.6

I'm running a docker in another docker via /var/run/docker.sock. It works with json-file logging driver or with docker run command, while it gots stuck when docker-py's client.containers.run() is used in combination with journald.

$ ls
Dockerfile
$ cat Dockerfile
FROM docker:18.09

RUN apk update && apk add python3 && pip3 install docker
$ docker build --no-cache -t test_image:latest .
...
$ cat /etc/docker/daemon.json
{
    "runtimes": {
        "nvidia": {
            "path": "nvidia-container-runtime",
            "runtimeArgs": []
        }
    }
}
$ docker run -v /var/run/docker.sock:/var/run/docker.sock -it test_image:latest docker run ubuntu:18.04 echo hello
hello
$ docker run -v /var/run/docker.sock:/var/run/docker.sock -it test_image:latest python3 -c 'import docker; docker_client = docker.from_env(); output = docker_client.containers.run("ubuntu:18.04", command=["echo", "hello"]); print(output.decode())'
hello

$ sudo vim /etc/docker/daemon.json
(edit it!)
$ cat
$ cat /etc/docker/daemon.json
{
    "log-driver": "journald",
    "log-opts": {
        "tag": "docker/{{.Name}}/{{.ID}}"
    },
    "runtimes": {
        "nvidia": {
            "path": "nvidia-container-runtime",
            "runtimeArgs": []
        }
    }
}
$ sudo systemctl restart docker
$ docker info | grep Logging
WARNING: No swap limit support
Logging Driver: journald
$ docker run -v /var/run/docker.sock:/var/run/docker.sock -it test_image:latest docker run ubuntu:18.04 echo hello
hello
$ docker run -v /var/run/docker.sock:/var/run/docker.sock -it test_image:latest python3 -c 'import docker; docker_client = docker.from_env(); output = docker_client.containers.run("ubuntu:18.04", command=["echo", "hello"]); print(output.decode())'
(got stuck. Ctrl-c)
$ docker run -v /var/run/docker.sock:/var/run/docker.sock -it test_image:latest python3 -c 'import docker; docker_client = docker.from_env(); output = docker_client.containers.run("ubuntu:18.04", stream=True, command=["echo", "hello"]); print(output.next().decode())'
hello

Is this an expected behavior?

environment detail:

$ cat /etc/os-release
NAME="Ubuntu"
VERSION="18.04.2 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.2 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic
$ docker version
Client:
 Version:           18.09.6
 API version:       1.39
 Go version:        go1.10.8
 Git commit:        481bc77
 Built:             Sat May  4 02:35:57 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.6
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.8
  Git commit:       481bc77
  Built:            Sat May  4 01:59:36 2019
  OS/Arch:          linux/amd64
  Experimental:     false

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the report through docker_client.containers.run() with the journald logging driver, comparing the default call with stream=True and the equivalent docker run command. Start at the containers.run entry point and the Docker Engine API interaction; done means the non-streaming call has a documented or corrected termination behavior for this setup.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, python
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.