Debug rails app inside docker use Intellij/Rubymine

I’m start working rails development with Docker.
Currently, I follow some tutorial to setup development environment.
Everything work well. (for build, run).
But now, I want to setup Ruby Remote SDK for Rubymine, so I installed SSH on docker container (the ruby container; I INSTALLED SSH BECAUSE IT’S NEEDED FOR SETTING REMOTE SDK).

Here is Dockerfile

  • nginx gunicorn flask packed inside docker compose with redis server. getting exit status on flask part of docker compose
  • can I use ansible to start docker swarm services without compose?
  • Install differnet Frameworks in docker container
  • Running php, apache and mysql with Docker & docker-compose
  • how to ignore some container when i run `docker-compose rm`
  • How to handle stage specific keystore in docker images
  • FROM ruby:2.2.0
    # Install package
    RUN apt-get update -qq && apt-get install -y \
        build-essential \
        libpq-dev \
        nodejs \
    # Setting sshd
    RUN mkdir /var/run/sshd
    RUN echo 'root:root' | chpasswd
    RUN sed -i 's/PermitRootLogin without-password/PermitRootLogin yes/' /etc/ssh/sshd_config
    RUN sed -ri 's/UsePAM yes/#UsePAM yes/g' /etc/ssh/sshd_config
    # SSH login fix. Otherwise user is kicked off after login
    RUN sed 's@session\s*required\s* optional' -i /etc/pam.d/sshd
    ENV NOTVISIBLE "in users profile"
    RUN echo "export VISIBLE=now" >> /etc/profile
    EXPOSE 22
    CMD ["/usr/sbin/sshd", "-D"]
    RUN mkdir /myapp
    WORKDIR /myapp
    ADD Gemfile /myapp/Gemfile
    ADD Gemfile.lock /myapp/Gemfile.lock
    RUN bundle install
    ADD . /myapp

    And docker-compose.yml

    version: '2'
        image: postgres
        build: .
        command: bundle exec rails s -p 3000 -b ''
          - .:/myapp
          - "3000:3000"
          - "22"
          - db

    (For ssh -> in flow this link

    Then I connect ssh to the container.
    Here is my steps:

    1. Get port of ssh:

      docker port demorailsdocker_web_1

      # Here is result

      22/tcp ->

      3000/tcp ->

    2. Connect ssh to container

      ssh root@localhost -p 32768

      # Result
      ssh_exchange_identification: Connection closed by remote host

    I figure out the problem is related to setup in Dockerfile.

    Because when I remove those lines in docker file:

    RUN mkdir /myapp
    WORKDIR /myapp
    ADD Gemfile /myapp/Gemfile
    ADD Gemfile.lock /myapp/Gemfile.lock
    RUN bundle install
    ADD . /myapp

    And remove those lines in docker-compose.yml

          - .:/myapp

    Then I can connect to SSH.

    I think the problem is about setting work dir.

    I can connect SSH well to the container by removed this line in docker-compose.yml

    command: bundle exec rails s -p 3000 -b ''

    So I think the problem is about rails.
    But I don’t know how to fix it.

  • env file-named volume in docker-compose
  • Server Error when logging in to a private docker registry from docker in docker
  • Python server app leaking memory
  • /var/run/docker.sock: permission denied while running docker within Python CGI script
  • How to run Nginx within a Docker container without halting?
  • Docker LAMP stack - where is the location to keep PHP projects?
  • One Solution collect form web for “Debug rails app inside docker use Intellij/Rubymine”

    Best I can tell you debug Ruby/Rails containers without the need to SSH in with the ruby-debug-ide gem that is made specifically for remote debugging:


    HOW TO:

    You could also use this Dockerfile that sets up SSH correctly that will allow you to remotely connect to your web container:



    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.