Skip to content

Instantly share code, notes, and snippets.

@davidraleigh
Last active June 29, 2017 17:38
Show Gist options
  • Save davidraleigh/a467f91f9bcdc28115a1b82524834d49 to your computer and use it in GitHub Desktop.
Save davidraleigh/a467f91f9bcdc28115a1b82524834d49 to your computer and use it in GitHub Desktop.
Debug Docker Container remotely
FROM test-image
# install supervisor just in case it isn't already installed
RUN apt-get update && apt-get install -y openssh-server supervisor
ADD *.conf /etc/supervisor/conf.d/
RUN mkdir -p /var/run/sshd /var/log/supervisor
ADD ./google_compute_engine.pub ./
ADD ./.pycharm_helpers /root/.pycharm_helpers
# http://www.linuxproblem.org/art_9.html
RUN mkdir /root/.ssh
RUN cat google_compute_engine.pub >> /root/.ssh/authorized_keys
RUN sed -i 's/#PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config
# SSH login fix. Otherwise user is kicked off after login
RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
ENV NOTVISIBLE "in users profile"
RUN echo "export VISIBLE=now" >> /etc/profile
EXPOSE 22
CMD ["/usr/bin/supervisord"]
[program:sshd]
directory=/usr/local/
command=/usr/sbin/sshd -D
autostart=true
autorestart=true
redirect_stderr=true
[supervisord]
logfile=/supervisord.log
pidfile=/var/run/supervisord.pid
nodaemon=true
@davidraleigh
Copy link
Author

copy your public key to the directory where you're building your machine:

gcloud compute copy-files ~/.ssh/google_compute_engine.pub davidraleigh@raleigh-dev-1604:/home/davidraleigh/debug-docker/ --zone=us-central1-b

@davidraleigh
Copy link
Author

must pull over pycharm helpers to your build machine's DebugDockerfile directory before building:

sudo gsutil cp -r gs://raleigh-data/2017.1.1/.pycharm_helpers ./

@davidraleigh
Copy link
Author

to ssh in you'll need to connect using root:

ssh -i ~/.ssh/google_compute_engine root@146.148.78.138 -p 52022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment