I'm trying to setup remote debugging to a Docker Debian container, to debug a Ruby application on my Windows laptop.
This is the post that lead me in this direction: https://intellij-support.jetbrains.com/hc/en-us/community/posts/207649545-Use-RubyMine-and-Docker-for-development-run-and-debug-before-deployment-for-testing-
I have the Ruby app and SSHD running in the container, though the recipe I found for configuring SSHD isn't fully compatible with the Linux distro that the Ruby image is based on.
I based my SSHD configuration on this Docker documentation page: https://docs.docker.com/engine/examples/running_ssh_service/
My image is based on the ruby:2.2 image from Docker Hub, which uses Debian 8 as opposed to Ubuntu 16.04 used in the SSHD example above.
I can get to a SSH prompt but I can't login with the screencast password for root that's set in the dockerfile.
I'm open to whatever solution works, either properly enabling root login or adding a new user with the correct permissions to allow for remote debugging. I'm just curious which path would be most straight forward in the Debian context. And if it's creating a new user, what permissions do they need?
Also, to be clear I'm treating this as a trial run and will obviously make sure to strip out the SSHD functionality in some way when I go to deploy the app for any context outside of development.
Thanks in advance for your help.
This is my current dockerfile
FROM ruby:2.2
RUN apt-get update && apt-get install -y \
build-essential \
libpq-dev \
nodejs \
openssh-server
RUN mkdir /var/run/sshd
RUN echo 'root:screencast' | chpasswd
RUN sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /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
RUN mkdir /MyApp
WORKDIR /MyApp
ADD Gemfile /MyApp/Gemfile
ADD Gemfile.lock /MyApp/Gemfile.lock
RUN bundle install
ADD . /MyApp
and this is my docker-compose.yml
version: '2'
services:
web:
build: .
command: /CivilService/docker-dev-start.sh
volumes:
- .:/CivilService
ports:
- "3000:3000"
- "3022:22"
The docker-dev-start.sh looks like this
#!/bin/bash
# start the SSH server for connecting the debugger in development
/usr/sbin/sshd -D &
bundle exec rails s -p 3000 -b '0.0.0.0'
Different distro's can have slightly different SSH configs so replacing specific strings might not work.
To cover any type of
PermitRootLogin
string use: