[RUBY] I built a rails environment with docker and mysql, but I got stuck

I made a rails environment in docker https://qiita.com/NA_simple/items/5e7f95ae58eec5d20e1f

If for some reason it doesn't work on the way, it seems that mysql-clients can't be installed. Refer to the URL below for how to rewrite. https://qiita.com/yagi_eng/items/1368fb2a234629a0c8e7

I'm addicted to it when I'm on the right track.

terminal


$ docker-compose run web rails db:create
Starting postgress_db ... done
Could not find activesupport-5.2.4.3 in any of the sources
Run `bundle install` to install missing gems.

Why is the ruby version different? ?? When I searched for the version in rbenv, I couldn't find 2.7.1. rbenv noticed old and updated

Update rbenv https://qiita.com/pugiemonn/items/f277440ec260b8d4fa6a

I noticed that the gem from was also old,

terminal


$ gem update

I haven't gone yet ... Perform bundler update.

I was desperate here and there, so I'll give it some time.

Organize once and start the procedure from the beginning of a different site.

https://toranoana-lab.hatenablog.com/entry/2020/06/05/173658

Start docker and access localhost without stopping! !! !! Alright! !! !! !!

localhost_3000


Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

Why: D It seems that there is no file when I google, so there are some articles that I forcibly make with sudo touch. But I deleted and created it thinking that there is a file

Same error.

?? ?? ?? I think, I notice that I have not launched mysql here This is it! !! !! I thought

terminal


mysql.server start

Is executed, but it does not start. Apparently when I google

terminal


sudo rm mysql.sock
brew uninstall mysql
brew install mysql

After deleting the sock file, uninstall mysql → install it. The path of mysql.sock was found in the previous error, so delete it

terminal


mysql.server start

... passed! !! !! !!

Did this go ...?

image.png

Yatter --------! !! !! !! !! !! !! !! !!

I think it was faster to build after understanding docker. Let's study again. myself.

Anyway, I'm glad I moved

Contents of each final file ↓

gemfile


source 'https://rubygems.org'
gem 'rails', '~>6'

docker-compose.yml


version: '3'
services:
  db:
    image: mysql:8.0
    environment:
      MYSQL_ROOT_PASSWORD:
    ports:
      - '3306:3306'
    command: --default-authentication-plugin=mysql_native_password
    volumes:
      - mysql-data:/var/lib/mysql
  web:
    build: .
    command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'"
    volumes:
      - .:/myapp
    ports:
      - "3000:3000"
    depends_on:
      - db
    stdin_open: true
    tty: true
    command: bundle exec rails server -b 0.0.0.0
volumes:
  mysql-data:
    driver: local

Dockerfile


FROM ruby:2.7
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 \
    && apt-get update -qq \
    && apt-get install -y nodejs yarn \
    && mkdir /myapp
WORKDIR /myapp
COPY Gemfile /myapp/Gemfile
COPY Gemfile.lock /myapp/Gemfile.lock
RUN bundle install
COPY . /myapp

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

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

Recommended Posts

I built a rails environment with docker and mysql, but I got stuck
Rails + MySQL environment construction with Docker
[Environment construction with Docker] Rails 6 & MySQL 8
I made a development environment with rails6 + docker + postgreSQL + Materialize.
I built a CentOS 8 environment with Vagrant and tried to sync_folder, but I got an error, so I solved it.
Building Rails 6 and PostgreSQL environment with Docker
Create Rails 6 + MySQL environment with Docker compose
Create a MySQL environment with Docker from 0-> 1
Procedure for building a Rails application development environment with Docker [Rails, MySQL, Docker]
Rails6 [API mode] + MySQL5.7 environment construction with Docker
[Rails & Docker & MySQL environment construction] I started the container, but I can't find MySQL ...?
Prepare a scraping environment with Docker and Java
When I tried to build an environment of PHP7.4 + Apache + MySQL with Docker, I got stuck [Windows & Mac]
[First environment construction] I tried to create a Rails 6 + MySQL 8.0 + Docker environment on Windows 10.
Build Rails (API) x MySQL x Nuxt.js environment with Docker
[Docker] Rails 5.2 environment construction with docker
[Rails] [Docker] Copy and paste is OK! How to build a Rails development environment with Docker
Easy environment construction of MySQL and Redis with Docker and Alfred
Rails application development environment construction with Docker [Docker, Rails, Puma, Nginx, MySQL]
Build a Node-RED environment with Docker to move and understand
Create Rails5 and postgresql environment with Docker and make pgadmin available
I tried to create a padrino development environment with Docker
Create a Vue3 environment with Docker!
Build a Node.js environment with Docker
Build environment with vue.js + rails + docker
Build Rails environment with Docker Compose
[Rails 6.0, Docker] I tried to summarize the Docker environment construction and commands necessary to create a portfolio
I got a warning message with the rails _6.0.3_ new hello_myapp command
How to build Rails + Vue + MySQL environment with Docker [2020/09 latest version]
Build a development environment for Django + MySQL + nginx with Docker Compose
"Rails 6 x MySQL 8" Docker environment construction procedure for sharing with teams
A story stuck with log output in Docker + Play framework environment
Rails environment construction with Docker (personal apocalypse)
Build a PureScript development environment with Docker
Deploy to heroku with Docker (Rails 6, MySQL)
Edit Mysql with commands in Docker environment
[Docker] Development environment construction Rails6 / Ruby2.7 / MySQL8
Laravel + MySQL + phpMyadmin environment construction with Docker
Build a Wordpress development environment with Docker
How to build Rails 6 environment with Docker
I was a little addicted to running old Ruby environment and old Rails
I tried to build a Firebase application development environment with Docker in 2020
[Copy and paste] Build a Laravel development environment with Docker Compose Part 2
[Docker] How to create a virtual environment for Rails and Nuxt.js apps
How to build a Ruby on Rails development environment with Docker (Rails 6.x)
Build a local development environment for Rails tutorials with Docker (Rails 6 + PostgreSQL + Webpack)
Launching the production environment with docker + rails (ver5.2) and errors that occurred
[Copy and paste] Build a Laravel development environment with Docker Compose Participation
Build a bulletin board API with authentication and authorization with Rails 6 # 1 Environment construction
How to build a Ruby on Rails development environment with Docker (Rails 5.x)
Template: Build a Ruby / Rails development environment with a Docker container (Ubuntu version)
Template: Build a Ruby / Rails development environment with a Docker container (Mac version)
I tried to make a machine learning application with Dash (+ Docker) part1 ~ Environment construction and operation check ~
Build a web application development environment that uses Java, MySQL, and Redis with Docker CE for Windows
Build a development environment for Docker + Rails6 + Postgresql
Where I got stuck in today's "rails tutorial" (2020/10/08)
[Memo] Create a CentOS 8 environment easily with Docker
Building an environment for WordPress, MySQL and phpMyAdmin with Docker Compose on EC2
Build a Laravel / Docker environment with VSCode devcontainer
(Basic authentication) environment variables in rails and Docker
Build a WordPress development environment quickly with Docker