-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
Capture the beginning of service output during run #4738
Conversation
Previously the container was started before pseudoterminal was started, therefore some of the output could've been lost. Goal of this commit is to make sure that all the input is printed out. To that end, the run command executes the following sequence: 1. connect container to networks 2. start pty 3. start container The original code was introduced in f3e5556 Signed-off-by: Jarek Lipski <loomchild@loomchild.net>
@@ -1160,8 +1160,9 @@ def remove_container(force=False): | |||
) | |||
pty = PseudoTerminal(project.client, operation) | |||
sockets = pty.sockets() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could simplify the code as follows:
pty.start(sockets)
service.start_container(container)
but I was worried to reintroduce a bug during interactive run with networking, as described in f3e5556
See docker/compose#4738 for more details.
Thank you for the detailed writeup and proposed fix. For context, Aanand's commit you're quoting is part of PR #2723, which has some tests attached. I want to assume that if those tests aren't breaking, that means the fix is preserved, but obviously it's good to be prudent. I'll take a closer look and do a real review when I have some time, but at first glance this looks reasonable. |
Interesting. I tried adding a couple of networks to my
then all of them are correctly displayed. However, if I try to apply the simple fix mentioned in my commit comment (invert |
Hi, did you have some time to look into this? Would you be interested in merging this pull request, perform some more tests or drop it as obsolete? Please let me know if I can help somehow. |
Hello @loomchild. Thanks for the PR, I could not reproduce the issue anymore. I'm closing this because the issue looks obsolete. |
@ulyssessouza I also cannot reproduce it anymore, must've been fixed in the meantime. Thanks. |
Issue
docker-compose up
always prints the entire container output, butdocker-compose run
sometimes skips the beginning of it.I wasn't able to reproduce this issue directly on local Linux machine, but when running docker-compose in docker container I can reproduce it every time.
Steps to reproduce:
Create the following
docker-compose.yml
:Create the following
Dockerfile
:Build the image
Pull the debian image to avoid doing it later (you can skip this step if you already have debian)
Run the container:
Execute docker-compose inside the container:
Expected output:
Actual output:
In other words everything before first
sleep
instruction is not displayed. However, when I add an additional sleep instruction at the beginning so the command indocker-compose.yml
looks like:And rebuild the container and re-execute the test, the output is correct.
The described issue could be related to #3239 / #3267 since the behavior described there seems to be pseudo random and it happens inside a VM.
Analysis
This seems to be caused by the fact that we start the container before initializing pseudoterminal (from cli/main.py,
run_one_off_container()
):I see that this code was introduced in below commit:
However, at this time the
start_container()
function was different and connected container to its networks after starting the container, as above commit message suggests:In the current code the order is inverted:
Proposed solution
Perhaps the sequence should be the following (see pull request):
I have tested the proposed fix locally and it resolves the original problem and doesn't break any of the automated tests. However, it can potentially reintroduce the aforementioned "interactive run with networking" bug - could you explain how to reproduce it?
Considering this issue occurs semi-randomly and only in specific circumstances, I am not sure how to correctly implement a test for it. However, seeing the extensive testing suite based on Docker, I'd be happy to dig deeper if you think it's useful and give me some hints.
Environment
docker-compose version
docker version
docker info