[RUBY] [Docker] List of errors that occurred when building the environment


I learned about Docker and decided to introduce Docker to existing Rails apps, so I did it while referring to the official quick start. I am posting the error that occurred at that time as a memorandum.


Ruby '2.6.5' Rails '6.0.0' Docker for Mac installed

Error case ①



FROM ruby:2.6.5

RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
    && echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list

RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs yarn

RUN mkdir /(app name)

WORKDIR /(app name)
COPY Gemfile /(app name)/Gemfile
COPY Gemfile.lock /(app name)/Gemfile.lock
RUN bundle install
COPY . /(app name)

COPY entrypoint.sh /usr/bin/
RUN chmod +x /usr/bin/entrypoint.sh
ENTRYPOINT ["entrypoint.sh"]

CMD ["rails", "server", "-b", ""]

The following error occurs when trying to launch with% docker-compose build

Error statement

Error statement

/usr/local/lib/ruby/2.6.0/rubygems.rb:283:in `find_spec_for_exe': Could not find 'bundler' (2.1.4) required by your /assist/Gemfile.lock. (Gem::GemNotFoundException)
To update to the latest version installed on your system, run `bundle update --bundler`.
To install the missing version, run `gem install bundler:2.1.4`
	from /usr/local/lib/ruby/2.6.0/rubygems.rb:302:in `activate_bin_path'
	from /usr/local/bin/bundle:23:in `<main>'
ERROR: Service 'web' failed to build : The command '/bin/sh -c bundle install' returned a non-zero code: 1


Inserting RUN gem install bundler solves it!


COPY Gemfile.lock /(app name)/Gemfile.lock
RUN gem install bundler
RUN bundle install

After investigating, it seems that the cause is that the version of bundler in the local environment and Docker is different, so an error occurred. If you put gem install bundler, it will be solved for the time being. .. .. There are still more. .. ..

Error case ②



version: "3"
    image: mysql:5.6.47
        MYSQL_ROOT_PASSWORD: password
        MYSQL_DATABASE: root
        - "3000:3000"
        - ./db/mysql/volumes:/var/lib/mysql
    build: .
    command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b ''"
    stdin_open: true
    tty: true
      - .:/(app name)
      - gem_data:/usr/local/bundle
      - "3000:3000"
      - db

After the docker-compose build was successful, when I ran the docker-compose up -d command,

Error statement


ERROR: for web  Cannot start service web: driver failed programming external connectivity on endpoint myapp_web_1 (ae889e882d7c9f8b72f9c9b244159d86662f4abebef7d15fac4016573fe56de4): Bind for failed: port is already allocated
ERROR: Encountered errors while bringing up the project.


Since the port numbers of the DB server and the web server were the same for 3000, I think the cause is that the web server does not start. It was a simple mistake. ..

I changed the DB port number to 3306 and fixed it.


        - "3306:3306"

Error case ③


After resolving the previous error, when I try to execute the docker-compose up command again, the following error occurs.

Error statement

warning Integrity check: System parameters don't match
error Integrity check failed
error Found 1 errors.
web_1  | 
web_1  | 
web_1  | ========================================
web_1  |   Your Yarn packages are out of date!
web_1  |   Please run `yarn install --check-files` to update.
web_1  | ========================================
web_1  | 
web_1  | 
web_1  | To disable this check, please change `check_yarn_integrity`
web_1  | to `false` in your webpacker config file (config/webpacker.yml).
web_1  | 
web_1  | 
web_1  | yarn check v1.22.5
web_1  | info Visit https://yarnpkg.com/en/docs/cli/check for documentation about this command.
web_1  | 
web_1  | 
web_1  | Exiting

At first glance, I felt as if I should upgrade yarn, so I ran the yarn upgrade command, but it didn't change. .. ..


If you take a closer look at the error statement, ...


web_1  | To disable this check, please change `check_yarn_integrity`
web_1  | to `false` in your webpacker config file (config/webpacker.yml).

Because there was a description like, when I went to the corresponding directory immediately


check_yarn_integrity: false

was! !! It was true by default, so rewriting it to false solved it! !! !! I will go to the last one. .. ..

Error case ④


docker-compose up -d succeeds and tries to access on localhost: 3000




It was simple. I forgot the db: create command. .. ..


% docker-compose exec web rails db:create
% docker-compose exec web rails db:migrate

At the end

Since the view file was completely corrupted, I will investigate the cause. .. .. ..

Recommended Posts

[Docker] List of errors that occurred when building the environment
Launching the production environment with docker + rails (ver5.2) and errors that occurred
About the solution of the error that occurred when trying to create a Japanese file of devise in the Docker development environment
Problems I was addicted to when building the digdag environment with docker
Improve the performance of your Docker development environment
Docker the development environment of Ruby on Rails project
Note that I stumbled upon building the Rails environment
Response to errors that occurred during installation of RMagick 4.1.2
A command that definitely cleans the local docker environment
SSL in the local environment of Docker / Rails / puma
List of Docker commands that I often use (container operation)
Docker × Java Building a development environment that is too simple
Docker monitoring-explaining the basics of basics-
Install by specifying the version of Django in the Docker environment
Setting the baseURL in the axios module of Docker environment Nuxt
Nginx container that displays the Hostname of the host running Docker
Specify the character code of the source when building with Maven
I tried to build the environment of WSL2 + Docker + VSCode
A program that counts the number of words in a List
[Docker] The story that an error occurred in docker-compose up
What I was addicted to when updating the PHP version of the development environment (Docker) from 7.2.11 to 7.4.x
A story that made me regret when a "NotReadablePropertyException" occurred during the development of the Spring Boot application.
I tried to build the environment of PlantUML Server with Docker
Install lsb_release from the command line when lsb_release fails in docker environment
I want to notice that I forgot to specify arg when building Docker
[Java] Delete the elements of List
This and that of the JDK
Official logo list of the service
Resolved the error that occurred when trying to use Spark in an environment where Java 8 and Java 11 coexist.
Incident (rails) that is logged out when user editing of the application
Run Redmine in the local environment of Windows10 Pro-Use Docker Desktop for Windows
Errors and solutions and reference articles that occurred when putting Heroku in Vagrant
Let's specify the version when using docker
Building Rails 6 and PostgreSQL environment with Docker
[Docker] Building an environment to use Hugo
The story of updating SonarQube's Docker Container
List of methods used when manipulating strings
How to sort the List of SelectItem
Show Better Errors in Rails + Docker environment
Commands that helped resolve errors in Docker
Try the Docker environment on AWS ECS
Procedure for introducing Docker into the development environment of existing Rails applications [Rails, MySQL, Docker]
Upcast (Java) that can reduce the amount of change when the specification is changed
Introduce Docker to the development environment and test environment of existing Rails and MySQL applications
A memorandum when building an environment with Ruby3.0 x Rails6.1 x Docker x CentOS Stream
Point memo that was moss when building a docker container created by a colleague
What to do when ‘Could not find’ in any of the sources appears in the development environment with Docker × Rails × RSpec
Report an example of performance degradation that occurred when the argument Comparator of Arrays.sort was given by a lambda expression