SSH or tmate access to running container
zupo opened this issue · 6 comments
Sometimes I need SSH access to a running container to debug certain issues. For example CI problems on CircleCI or on GitHub Actions. For latter, there is https://github.com/marketplace/actions/debugging-with-tmate, but that depends on having a bunch of ubuntu things available. Can we do something similar?
CircleCI's "Rerun Job with SSH" also seems like it does not work. The job starts and prints out the IP to connect to, but when I try to connect I get connection refused
.
@zupo Regarding CircleCI's "Rerun Job with SSH", that seems to work in my testing. See https://github.com/Infinisil/github-actions-docker for the CircleCI config I used.
@infinisil: oh wow, OK, lemme re-test it!
I also just added very easy support for starting a tmate
session in the image, see https://github.com/niteoweb/nix-docker-base#connecting-with-ssh-during-ci. For GitHub Actions, one can use
defaults:
run:
shell: bash-tmate {0}
To make it start a tmate session when any run
step fails. Similarly for CircleCI:
executors:
my-executor:
docker:
- image: niteo/nixpkgs-nixos-unstable:1dc37370c489b610f8b91d7fdd40633163ffbafd
shell: bash-tmate -eo pipefail
Confirmed that CircleCI SSH works fine.
I couldn't get bash-tmate -eo pipefail
to work on GHA, but - run: bash-tmate {0}
does in fact work for me in GitHub Actions. Yay!