[RUBY] How to execute with commands of normal development language in Docker development environment

In the Docker development environment, it is necessary to operate with commands specific to the Docker development environment, but we will introduce a method that allows you to develop with the same commands as when executing commands in the script language in the local environment.

environment

Docker 19.03.8 Ruby 2.5 Rails 5.2

Differences between running in Docker and a local development environment

For example, the following commands used in the development of Ruby on Rails

$ rails db:migrate

When executing this command with Docker

$ docker-compose run web rails db:migrate

The command looks like this. There are other operation methods, but if you develop with Ruby on Rails, normal commands of Ruby and Rails are easier. In that case, execute the command according to the following procedure.

Preparing to develop with normal Ruby commands

Launch Docker.

$ docker-compose start

Look up the container name.

$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
a9b19e00552e        recipegram_web      "entrypoint.sh bash …"   44 hours ago        Up 11 seconds       0.0.0.0:3000->3000/tcp   recipegram_web_1
975875c12c76        postgres            "docker-entrypoint.s…"   46 hours ago        Up 12 seconds       5432/tcp                 recipegram_db_1

Enter the container name and execute the following command.

$ docker exec -it a9b19e00552e bash

Then it will switch like this, so in this state you can develop with Ruby or Rails execution command ^ _ ^

root@a9b19e00552e:/myapp#

Recommended Posts

How to execute with commands of normal development language in Docker development environment
How to build Rails, Postgres, ElasticSearch development environment with Docker
How to use git with the power of jgit in an environment without git commands
Edit Mysql with commands in Docker environment
How to execute multiple commands in docker-compose.yml
How to build Rails 6 environment with Docker
How to install Pry after building Rails development environment with Docker
Self-hosting with Docker of AuteMuteUs in Windows environment
I tried to build a Firebase application development environment with Docker in 2020
How to build a Ruby on Rails development environment with Docker (Rails 6.x)
How to build a Ruby on Rails development environment with Docker (Rails 5.x)
[Rails] How to build an environment with Docker
How to build an environment of [TypeScript + Vue + Express + MySQL] with Docker ~ Vue edition ~
How to build docker environment with Gradle for intelliJ
[Docker environment] How to deal with ActiveSupport :: MessageEncryptor :: InvalidMessage
How to delete untagged images in bulk with Docker
How to build Java development environment with VS Code
How to boot by environment with Spring Boot of Maven
How to install Docker in the local environment of an existing Rails application [Rails 6 / MySQL 8]
[Rails] [Docker] Copy and paste is OK! How to build a Rails development environment with Docker
How to quit Docker for Mac and build a Docker development environment with Ubuntu + Vagrant
[Rough explanation] How to separate the operation of the production environment and the development environment with Rails
How to implement one-line display of TextView in Android development
I tried to create a padrino development environment with Docker
[Docker context] ~ How to access docker in remote environment from VScode ~
What to do when ‘Could not find’ in any of the sources appears in the development environment with Docker × Rails × RSpec
How to manage the difference in each environment with yml without increasing the number of RAILS_ENV
How to start Camunda with Docker
I tried to build the environment of PlantUML Server with Docker
How to build [TypeScript + Vue + Express + MySQL] environment with Docker ~ MySQL edition ~
How to run a job with docker login in AWS batch
PostgreSQL environment construction with Docker (from setup to just before development)
How to install the language used in Ubuntu and how to build the environment
How to build Rails + Vue + MySQL environment with Docker [2020/09 latest version]
How to build [TypeScript + Vue + Express + MySQL] environment with Docker ~ Sequelize ~
Alert slack with alert manager in Docker environment
How to share files with Docker Toolbox
How to reflect seeds.rb in production environment
Laravel development environment construction with Docker (Mac)
Build a PureScript development environment with Docker
Create Spring Boot-gradle-mysql development environment with Docker
How to use Docker in VSCode DevContainer
Build a Wordpress development environment with Docker
How to use environment variables in RubyOnRails
Understand in 5 minutes !! How to use Docker
Lightweight PHP 7.4 development environment created with Docker
How to run Blazor (C #) with Docker
[Node.js express Docker] How to define Docker environment variables and load them with node.js
How to migrate a web application created in a local docker environment to AWS
Android development, how to check null in the value of JSON object
How to start a Docker container with a volume mounted in a batch file
How to insert processing with any number of elements in iterative processing in Ruby
Summary of how to select elements in Selenium
How to check the logs in the Docker container
Prepare the JVM language development environment with WSL
How to get the ID of a user authenticated with Firebase in Swift
Build a WordPress development environment quickly with Docker
[Laravel] How to deal with out of memory error when composer require [Docker]
Improve the performance of your Docker development environment
How to install Titan2D (v4.2.0) in virtual environment
How to update pre-built files in docker container