如何configurationDebian SSHD在Docker容器中进行远程debugging?

我试图设置远程debugging到一个Docker Debian容器,以debugging我的Windows笔记本电脑上的Ruby应用程序。

这是引导我在这个方向的职位: https : //intellij-support.jetbrains.com/hc/en-us/community/posts/207649545-Use-RubyMine-and-Docker-for-development-run-and -debug-前部署换testing-

我在容器中运行了Ruby应用程序和SSHD,但是我发现configurationSSHD的配方与Ruby映像所基于的Linux发行版不完全兼容。

我在此Docker文档页面上configuration了我的SSHDconfiguration: https : //docs.docker.com/engine/examples/running_ssh_service/

我的图像是基于ruby:2.2的Docker Hub镜像,它使用Debian 8而不是上面的SSHD示例中使用的Ubuntu 16.04。

我可以到达SSH提示符,但是我无法使用在dockerfile中设置的根目录的屏幕录像密码进行login。

我打开任何解决scheme的工作,要么正确启用根login或添加一个新的用户具有正确的权限,以允许远程debugging。 我只是好奇Debian上下文中最直接的path。 如果它创build一个新的用户,他们需要什么权限?

另外,为了清楚起见,我把这个作为一个试运行来处理,当我去部署应用程序用于任何开发之外的环境时,显然将确保以某种方式去除SSHDfunction。

在此先感谢您的帮助。

这是我目前的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 

这是我的docker-compose.yml

 version: '2' services: web: build: . command: /CivilService/docker-dev-start.sh volumes: - .:/CivilService ports: - "3000:3000" - "3022:22" 

docker-dev-start.sh看起来像这样

 #!/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' 

不同的发行版可以有略微不同的SSHconfiguration,因此replace特定的string可能无法正常工作。

要覆盖任何types的PermitRootLoginstring,请使用:

 RUN sed -i 's/PermitRootLogin .*/PermitRootLogin yes/' /etc/ssh/sshd_config