Skip to content

docker start -i fails to attach to stdin  #10514

@WhisperingChaos

Description

@WhisperingChaos
Steps To Reproduce
  • Create an image using the following Dockerfile source:
    FROM       ubuntu:12.04
    RUN echo "dlw_sshserver">/root/ComponentName.txt
    ENTRYPOINT  /bin/bash

The above essentially creates a bash command shell.

  • Test 1
    • Execute image: 'docker run <imageGUID>.' Container 'X' is created and since STDIN wasn't left open with '-i' option, the bash process terminates and the container transitions to the stopped state.
    • Now start newly created container 'X' requesting interactive mode: 'docker start -i <XGUID>.' Container executes but fails to connect its STDIN to current terminal session and then transitions to the stopped state.
  • Test 2
    • Execute image but this time enable interactive option: 'docker run -i <imageGUID>.' Container 'Y' is created and since STDIN is open with '-i' option, the current command terminal connects to the container's executing bash process. The container remains running and responsive.
    • Stop running the 'Y' container: 'docker stop <YGUID>.' The 'Y' container transitions to the stopped state.
    • Start running the 'Y' container requesting interactive mode: 'docker start -i <YGUID>.' Under these circumstances and in opposition to the behavior of 'Test 1', the start command connects the Y container's STDIN and the container remains running and responsive.
Environment
  • Using docker version 1.3.1.
  • Ubuntu 12.04.4 LTS
Behavior Assessment

Why the different behavior between the 'start' command of 'Test 1' vs the 'start' of 'Test 2'? After reviewing the image meta data for both 'X' and 'Y' containers using the docker inspect command, the differing behavior between the containers seems related to the Config.OpenStdin option. The boolean setting for this 'Y' container field is 'true', as established by the docker run command, while 'X's value is 'false'. This boolean setting not only advertises the capability of the container, but also determines its availability. Specifying the availability of a container option must be what's conveyed by the phrase "...final control to the operator who starts the container from the image." that appears in the docker run documentation.

Since run options of '-i' and '-a' are also accepted by start, unlike other options that are immutable, like the volumes option -v, it's not apparent that the availability of these options is controlled by the run command and that the '-a' and '-i' options of the start command can only affect the values of these options made accessible by run. There's nothing mentioned by reading the documentation of of start that alerts readers to this intentionally designed behavior. Besides augmenting the 'start' command's documentation, perhaps a more descriptive explanation of 'final control' could be incorporated into the run documentation.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions