Open ghost opened 8 years ago
I had the same problem. The docker process is not killed when you detach the interactive shell. I added a few lines after context.pty.Close() in "goHandleClient" to call "docker kill" and "docker rm" to clean up the container.
+1
A workaround to prevent a container from living indefinitely is to add a timeout on the interactive process, so you can be sure the container is always terminated.
MAX_CONTAINER_AGE=30 # seconds
gotty --permit-write docker run --rm -it ubuntu timeout $MAX_CONTAINER_AGE bash
Of course it would be ideal if clients remembered to exit
from the shell before closing the browser window.
I've resolved this issue partially. Now the docker
command, which is just a client, is closed properly by SIGHUP
.
However, docker itself has an issue on the --sig-proxy
option (https://github.com/moby/moby/issues/28872). We need an upstream fix for the ultimate resolution
A workaround to all this would be not to run a docker command with GoTTY but rathern run GoTTY inside a container itself. Here is an example Dockerfile:
FROM golang RUN go get github.com/yudai/gotty ENTRYPOINT ["gotty"]
tested on Arch Linux / GoTTY 0.0.12.
I ran:
docker ps
at that time:after that I opened server:8080:
and close it:
busybox is still there.
here is the log from gotty: