- Initially install your pry-rails to group development on your apps Gemfile
group :development do
# ..
gem 'pry-rails'
# ..
end
- Then make sure that your docker-compose.yml contains in the app container the following two:
app:
..
..
tty: true
stdin_open: true
- Add binding.pry to the desired place you want to have a look on your rails code:
def index
binding.pry
end
- Run your docker app container and get the container id
docker-compose up app
and open a seperate terminal to run docker ps and get the container id:
docker ps
and you will get something like the following:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e5410d059f31 mariadb:10.1 "docker-entrypoint..." 13 days ago Up 13 days 3306/tcp msdsecs_mariadb_1
2557eef7f95c redis "docker-entrypoint..." 13 days ago Up 13 days 6379/tcp msdsecs_redis_1
5fd1e9f0d850 msdsadd_sidekiq "/app/docker_helpe..." 7 weeks ago Up 42 hours 3000/tcp, 0.0.0.0:6666->6666/tcp msdsadd_sidekiq_1
a38aaff4b63e mariadb:10.1 "docker-entrypoint..." 3 months ago Up 42 hours 3306/tcp msdsadd_mariadb_1
f2c0047944dd redis "docker-entrypoint..." 3 months ago Up 42 hours 6379/tcp msdsadd_redis_1
With container id in hand, you can attach the terminal to the docker instance:
docker attach e5410d059f31
where e5410d059f31 is the container id of the app. You will get your pry on the attached terminal.
@andersonreinkordt Same issue! No input recognized it seems