RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1113608 - `docker attach` hangs when attaching container, which is exiting
Summary: `docker attach` hangs when attaching container, which is exiting
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: docker
Version: 7.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Lokesh Mandvekar
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks: 1138364
TreeView+ depends on / blocked
 
Reported: 2014-06-26 13:50 UTC by Lukáš Doktor
Modified: 2019-03-06 02:41 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-03-05 03:19:04 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2015:0623 0 normal SHIPPED_LIVE Low: docker security, bug fix, and enhancement update 2015-03-05 15:28:35 UTC

Description Lukáš Doktor 2014-06-26 13:50:03 UTC
Description of problem:
When you execute `docker attach` on a container, which is in the process of shutting down, the process doesn't fail, but hangs for ever.

Even when you remove (`docker rm`) the container afterwards, the process still exists and when you use eg. ctrl+c, it complains about missing container.

When you have stdin attached, it finishes after an input, otherwise you have to use `kill -9` to get rid of it.

Version-Release number of selected component (if applicable):
docker-0.11.1-10.el7.x86_64
docker-io-1.0.0-3.fc20.x86_64

How reproducible:
rarely on RHEL7 (0.11.1), always on Fedora 20 (1.0.0-3)

Steps to Reproduce:
1. in 1st terminal execute: "while :; do sudo docker -D attach  `sudo docker ps -l -q`; done"
2a. in 2nd terminal execute: "docker run -i -t fedora bash" and when the first terminal attaches, use `exit` or `ctrl+d` to stop the container.
2b. when the 2a doesn't causes the bug, use this script to start-stop containers in a loop: "while :; do ID=`docker run -d -i -t fedora bash`; sleep 1; echo exit | docker attach $ID; done"

Actual results:
On Fedora after step 2a the attach process in 1st terminal hangs, there is no new input.
On RHEL after a while while executing the 2b script, the attach process in 1st terminal hangs.

Expected results:
The attach process in 1st terminal should finish when the container is destroyed and lots of messages like:

2014/06/26 15:29:55 You cannot attach to a stopped container, start it first
2014/06/26 15:29:55 You cannot attach to a stopped container, start it first
2014/06/26 15:29:55 You cannot attach to a stopped container, start it first
2014/06/26 15:29:55 You cannot attach to a stopped container, start it first

should occur (as we are trying to attach stopped container).


Additional info:
When you use `docker attach --no-stdin ...` you can write anything. After a ctrl+c it realizes the container is not running and finishes. ctrl+p+q doesn't work. In RHEL version when you remove the container by `docker rm` first, ctrl+c generates message in docker daemon, that the container with id ... doesn't exist and the `docker attach` process is still hanged.

When you have stdin attached, after sending any character the process is destoyed with:
[debug] hijack.go:96 [hijack] End of stdout
                                           2014/06/26 15:49:31 You cannot attach to a stopped container, start it first

Comment 5 Daniel Walsh 2014-08-22 13:18:35 UTC
Upstream found a bug in docker (Caused by a fix from me) blocks interactive terminals from exiting.

Might fix this problem.

Comment 6 Lukáš Doktor 2014-09-09 13:08:45 UTC
OK I tried that on F21 with docker-io-1.2.0-2.fc21.x86_64 and it works fine (no failure after couple of hours).

Comment 7 Daniel Walsh 2014-09-09 13:59:40 UTC
Great,

Comment 8 Daniel Walsh 2014-09-12 17:13:15 UTC
Fixed in docker-1.2

Comment 10 Luwen Su 2015-01-28 08:59:59 UTC
With docker-1.4.1-27.el7.x86_64,
run the script
# cat 1113608.sh 
# /bin/bash
while :; do ID=`docker run -d -i -t rhel7 bash`; sleep 1; echo exit | docker attach $ID; done

generated 
FATA[0000] cannot enable tty mode on non tty input      
FATA[0000] cannot enable tty mode on non tty input 

no hang here, so move to verify

Comment 12 errata-xmlrpc 2015-03-05 03:19:04 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHSA-2015-0623.html


Note You need to log in before you can comment on or make changes to this bug.