Last active
June 29, 2017 17:38
-
-
Save davidraleigh/a467f91f9bcdc28115a1b82524834d49 to your computer and use it in GitHub Desktop.
Debug Docker Container remotely
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[program:sshd] | |
directory=/usr/local/ | |
command=/usr/sbin/sshd -D | |
autostart=true | |
autorestart=true | |
redirect_stderr=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[supervisord] | |
logfile=/supervisord.log | |
pidfile=/var/run/supervisord.pid | |
nodaemon=true |
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 ./
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
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