`docker attach` in Google Compute Engine VM not showing output, cannot exit back to shell

Viewed 39

I have a container with a python script that runs at startup, that I'm using to verify basic VM functionality.

    while True:
        print('Looping forever')
        time.sleep(3)
        pass

I have deployed this to a GCE VM instance with stdin buffer enabled.

  • The GCE instance is green-checkmarked.
  • I can connect to the VM using browser window ssh and see the container running.
  • I can docker attach to the active container.

What's not working:

  • I don't see any output from the script when I look at the VM logs in the Google Cloud console.
  • I don't see any output when attached to the active container. I can't use Ctrl+C or Ctrl+Z to exit back to shell.
  • I can docker run $image inside the ssh session, but I don't see any output and can't exit back to shell (same problem as with docker attach above).
  • If I close the browser ssh window and open a new browser ssh window, I can now see two containers running, the original one and the one that I launched in the previous ssh session using docker run.

I feel like there is something stupidly trivial that I've forgotten to set up.

===== EDIT =====

I found that even when I docker run locally, I don't see output and can't exit. I have to use kill in another terminal window to kill it.

When I run docker run -it $image in the VM's browser ssh terminal, I also see the output, which is good.

I think there's some behavior of docker attach that is working as intended, just not intuitive. I'd still like to achieve one of these goals:

  • Be able to see the output from the running container in the VM ssh session.
  • Be able to see the output from the running container in cloud logs.
1 Answers
Related