[Rails] How to use rails console with docker

This is a personal memo.

How to access the rails console of an application running with docker.

Run rails c inside the docker container.

Launch rails console


##Check the name of the container you want to enter
docker ps

##Enter the container
docker exec -it container name/bin/bash

##open rails console
[email protected]:/app# rails c

`Redis#exists(key)` will return an Integer by default in redis-rb 4.3. The option to explicitly disable this behaviour via `Redis.exists_returns_integer` will be removed in 5.0. You should use `exists?` instead.
Loading development environment (Rails


The terminal changes in the order of local ($)-> docker (root @ 96913c74e902 :)-> rails (irb (main)).

irb is an interactive mode of rails. Abbreviation for Interactive Ruby.

## Termination method and precautions `Exit` or` quit` when exiting.


##It cannot be removed if the end is other than 0 (it is considered to be in the middle of the expression)
irb(main):014:2> quit
irb(main):015:2> exit

##ctrl +Clear with c and then exit
irb(main):017:0> exit 

## Command execution example

For one line

irb(main):001:0> p "hello rails"
"hello rails"
=> "hello rails"

irb(main):002:0> 1+2
=> 3

For multiple lines

irb(main):015:0> for i in 1...11 do
irb(main):016:1*   print "#{i} "
irb(main):017:1> end
1 2 3 4 5 6 7 8 9 10 => 1...11

Recommended Posts

[Rails] How to use rails console with docker
How to build Rails 6 environment with Docker
[Rails] How to use enum
[Rails] How to use enum
How to use rails join
[Rails] How to use validation
How to use docker compose with NVIDIA Jetson
[Rails] How to use authenticate_user!
[Rails] How to use "kaminari"
How to use nginx-ingress-controller with Docker for Mac
[Rails] How to build an environment with Docker
[Docker] Use whenever with Docker + Rails
[Rails] How to use Scope
[Docker + Rails] How to deal with Rails server startup failure
[Rails] How to use gem "devise"
[Rails] How to use devise (Note)
[Rails] How to use flash messages
How to use Ruby on Rails
How to use mssql-tools with alpine
[Rails] How to use Active Storage
[Artifactory] How to use Docker repository
How to get along with Rails
[Introduction to Rails] How to use render
How to start Camunda with Docker
How to build Rails, Postgres, ElasticSearch development environment with Docker
How to use mysql with M1 mac Docker preview version
How to share files with Docker Toolbox
How to use custom helpers in rails
[Ruby on Rails] How to use CarrierWave
How to use BootStrap with Play Framework
[Rails] How to use ActiveRecord :: Bitemporal (BiTemporalDataModel)
Deploy to heroku with Docker (Rails 6, MySQL)
[Rails] How to use the map method
How to use Docker in VSCode DevContainer
How to use MySQL in Rails tutorial
[Ruby on Rails] How to use redirect_to
[Note] How to use Rails 6 Devise + cancancan
[Ruby on Rails] How to use kaminari
[Rails] How to use video_tag to display videos
Understand in 5 minutes !! How to use Docker
[Rails] How to use helper method, confimartion
How to use credentials.yml.enc introduced in Rails 5.2
How to run Blazor (C #) with Docker
How to install Pry after building Rails development environment with Docker
How to build Rails + Vue + MySQL environment with Docker [2020/09 latest version]
[For those who create portfolios] How to use binding.pry with Docker
How to use Map
How to write Rails
How to use rbenv
How to use letter_opener_web
How to use with_option
How to use fields_for
How to use map
Rails deploy with Docker
How to use collection_select
Use Puphpeteer with Docker
How to use Twitter4J
How to use active_hash! !!
How to install Docker
How to use MapStruct
How to use hidden_field_tag