Поведение с ошибками
Я использую docker -композит в Ubuntu 18.04 для работы с некоторыми Ruby на Rails проекты, однако, каждый раз, когда я пытаюсь использовать консоль rails, я получаю следующую ошибку:
/usr/local/bundle/gems/rb-inotify-0.9.10/lib/rb-inotify/notifier.rb:192:in `initialize': Permission denied @ dir_initialize - /usr/src/app/docker/mysql/data/performance_schema (Errno::EACCES)
from /usr/local/bundle/gems/rb-inotify-0.9.10/lib/rb-inotify/notifier.rb:192:in `new'
from /usr/local/bundle/gems/rb-inotify-0.9.10/lib/rb-inotify/notifier.rb:192:in `watch'
from /usr/local/bundle/gems/rb-inotify-0.9.10/lib/rb-inotify/notifier.rb:202:in `block in watch'
from /usr/local/bundle/gems/rb-inotify-0.9.10/lib/rb-inotify/notifier.rb:194:in `each'
from /usr/local/bundle/gems/rb-inotify-0.9.10/lib/rb-inotify/notifier.rb:194:in `watch'
from /usr/local/bundle/gems/rb-inotify-0.9.10/lib/rb-inotify/notifier.rb:202:in `block in watch'
from /usr/local/bundle/gems/rb-inotify-0.9.10/lib/rb-inotify/notifier.rb:194:in `each'
from /usr/local/bundle/gems/rb-inotify-0.9.10/lib/rb-inotify/notifier.rb:194:in `watch'
from /usr/local/bundle/gems/rb-inotify-0.9.10/lib/rb-inotify/notifier.rb:202:in `block in watch'
from /usr/local/bundle/gems/rb-inotify-0.9.10/lib/rb-inotify/notifier.rb:194:in `each'
from /usr/local/bundle/gems/rb-inotify-0.9.10/lib/rb-inotify/notifier.rb:194:in `watch'
from /usr/local/bundle/gems/rb-inotify-0.9.10/lib/rb-inotify/notifier.rb:202:in `block in watch'
from /usr/local/bundle/gems/rb-inotify-0.9.10/lib/rb-inotify/notifier.rb:194:in `each'
from /usr/local/bundle/gems/rb-inotify-0.9.10/lib/rb-inotify/notifier.rb:194:in `watch'
from /usr/local/bundle/gems/listen-3.1.5/lib/listen/adapter/linux.rb:32:in `_configure'
from /usr/local/bundle/gems/listen-3.1.5/lib/listen/adapter/base.rb:45:in `block in configure'
from /usr/local/bundle/gems/listen-3.1.5/lib/listen/adapter/base.rb:40:in `each'
from /usr/local/bundle/gems/listen-3.1.5/lib/listen/adapter/base.rb:40:in `configure'
from /usr/local/bundle/gems/listen-3.1.5/lib/listen/adapter/base.rb:63:in `start'
from /usr/local/bundle/gems/listen-3.1.5/lib/listen/listener.rb:68:in `block in <class:Listener>'
from /usr/local/bundle/gems/listen-3.1.5/lib/listen/fsm.rb:121:in `instance_eval'
from /usr/local/bundle/gems/listen-3.1.5/lib/listen/fsm.rb:121:in `call'
from /usr/local/bundle/gems/listen-3.1.5/lib/listen/fsm.rb:91:in `transition_with_callbacks!'
from /usr/local/bundle/gems/listen-3.1.5/lib/listen/fsm.rb:57:in `transition'
from /usr/local/bundle/gems/listen-3.1.5/lib/listen/listener.rb:91:in `start'
from /usr/local/bundle/gems/spring-watcher-listen-2.0.1/lib/spring/watcher/listen.rb:27:in `start'
from /usr/local/bundle/gems/spring-2.0.2/lib/spring/application.rb:80:in `start_watcher'
from /usr/local/bundle/gems/spring-2.0.2/lib/spring/application.rb:89:in `preload'
from /usr/local/bundle/gems/spring-2.0.2/lib/spring/application.rb:153:in `serve'
from /usr/local/bundle/gems/spring-2.0.2/lib/spring/application.rb:141:in `block in run'
from /usr/local/bundle/gems/spring-2.0.2/lib/spring/application.rb:135:in `loop'
from /usr/local/bundle/gems/spring-2.0.2/lib/spring/application.rb:135:in `run'
from /usr/local/bundle/gems/spring-2.0.2/lib/spring/application/boot.rb:19:in `<top (required)>'
from /usr/local/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /usr/local/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from -e:1:in `<main>'
Я могу заставить консоль работать, введя команду bash и изменение разрешений для папки mysql, в которой хранится изображение, с помощью следующей команды:
sudo chown -R myuser:myuser docker/mysql/
Однако при этом другие функции рельсов ломаются. Например, команда rails db:reset
выдает следующую ошибку:
-- create_table("actions", {:force=>:cascade, :options=>"ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC"})
rails aborted!
ActiveRecord::StatementInvalid: Mysql2::Error: Can't create table 'actions' (errno: 13): CREATE TABLE `actions` (`id` bigint NOT NULL AUTO_INCREMENT PRIMARY KEY, `workflow_id` bigint, `type` varchar(191), `settings` text, `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL, INDEX `index_actions_on_type_and_workflow_id` (`type`, `workflow_id`), INDEX `index_actions_on_workflow_id` (`workflow_id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC
/usr/local/bundle/gems/mysql2-0.4.10/lib/mysql2/client.rb:120:in `_query'
/usr/local/bundle/gems/mysql2-0.4.10/lib/mysql2/client.rb:120:in `block in query'
/usr/local/bundle/gems/mysql2-0.4.10/lib/mysql2/client.rb:119:in `handle_interrupt'
/usr/local/bundle/gems/mysql2-0.4.10/lib/mysql2/client.rb:119:in `query'
/usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:214:in `block (2 levels) in execute'
/usr/local/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies/interlock.rb:46:in `block in permit_concurrent_loads'
/usr/local/bundle/gems/activesupport-5.1.4/lib/active_support/concurrency/share_lock.rb:185:in `yield_shares'
/usr/local/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies/interlock.rb:45:in `permit_concurrent_loads'
/usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:213:in `block in execute'
/usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract_adapter.rb:612:in `block (2 levels) in log'
/usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract_adapter.rb:611:in `block in log'
/usr/local/bundle/gems/activesupport-5.1.4/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract_adapter.rb:603:in `log'
/usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:212:in `execute'
/usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/connection_adapters/mysql/database_statements.rb:26:in `execute'
/usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract/schema_statements.rb:288:in `create_table'
/usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:363:in `create_table'
/usr/src/app/config/initializers/utf8mb4.rb:7:in `create_table'
/usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/migration.rb:849:in `block in method_missing'
/usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/migration.rb:818:in `block in say_with_time'
/usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/migration.rb:818:in `say_with_time'
/usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/migration.rb:838:in `method_missing'
/usr/src/app/db/schema.rb:15:in `block in <top (required)>'
/usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/schema.rb:48:in `instance_eval'
/usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/schema.rb:48:in `define'
/usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/schema.rb:44:in `define'
/usr/src/app/db/schema.rb:13:in `<top (required)>'
/usr/local/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:286:in `load'
/usr/local/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:286:in `block in load'
/usr/local/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:258:in `load_dependency'
/usr/local/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:286:in `load'
/usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/tasks/database_tasks.rb:233:in `load_schema'
/usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/tasks/database_tasks.rb:255:in `block in load_schema_current'
/usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/tasks/database_tasks.rb:304:in `block in each_current_configuration'
/usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/tasks/database_tasks.rb:303:in `each'
/usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/tasks/database_tasks.rb:303:in `each_current_configuration'
/usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/tasks/database_tasks.rb:254:in `load_schema_current'
/usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/railties/databases.rake:248:in `block (3 levels) in <top (required)>'
/usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/railties/databases.rake:252:in `block (3 levels) in <top (required)>'
/usr/local/bundle/gems/railties-5.1.4/lib/rails/commands/rake/rake_command.rb:21:in `block in perform'
/usr/local/bundle/gems/railties-5.1.4/lib/rails/commands/rake/rake_command.rb:18:in `perform'
/usr/local/bundle/gems/railties-5.1.4/lib/rails/command.rb:46:in `invoke'
/usr/local/bundle/gems/railties-5.1.4/lib/rails/commands.rb:16:in `<top (required)>'
/usr/src/app/bin/rails:9:in `require'
/usr/src/app/bin/rails:9:in `<top (required)>'
/usr/local/bundle/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load'
/usr/local/bundle/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call'
/usr/local/bundle/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call'
/usr/local/bundle/gems/spring-2.0.2/lib/spring/client.rb:30:in `run'
/usr/local/bundle/gems/spring-2.0.2/bin/spring:49:in `<top (required)>'
/usr/local/bundle/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load'
/usr/local/bundle/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>'
/usr/src/app/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
Caused by:
Mysql2::Error: Can't create table 'actions' (errno: 13)
/usr/local/bundle/gems/mysql2-0.4.10/lib/mysql2/client.rb:120:in `_query'
/usr/local/bundle/gems/mysql2-0.4.10/lib/mysql2/client.rb:120:in `block in query'
/usr/local/bundle/gems/mysql2-0.4.10/lib/mysql2/client.rb:119:in `handle_interrupt'
/usr/local/bundle/gems/mysql2-0.4.10/lib/mysql2/client.rb:119:in `query'
/usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:214:in `block (2 levels) in execute'
/usr/local/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies/interlock.rb:46:in `block in permit_concurrent_loads'
/usr/local/bundle/gems/activesupport-5.1.4/lib/active_support/concurrency/share_lock.rb:185:in `yield_shares'
/usr/local/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies/interlock.rb:45:in `permit_concurrent_loads'
/usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:213:in `block in execute'
/usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract_adapter.rb:612:in `block (2 levels) in log'
/usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract_adapter.rb:611:in `block in log'
/usr/local/bundle/gems/activesupport-5.1.4/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract_adapter.rb:603:in `log'
/usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:212:in `execute'
/usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/connection_adapters/mysql/database_statements.rb:26:in `execute'
/usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract/schema_statements.rb:288:in `create_table'
/usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:363:in `create_table'
/usr/src/app/config/initializers/utf8mb4.rb:7:in `create_table'
/usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/migration.rb:849:in `block in method_missing'
/usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/migration.rb:818:in `block in say_with_time'
/usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/migration.rb:818:in `say_with_time'
/usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/migration.rb:838:in `method_missing'
/usr/src/app/db/schema.rb:15:in `block in <top (required)>'
/usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/schema.rb:48:in `instance_eval'
/usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/schema.rb:48:in `define'
/usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/schema.rb:44:in `define'
/usr/src/app/db/schema.rb:13:in `<top (required)>'
/usr/local/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:286:in `load'
/usr/local/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:286:in `block in load'
/usr/local/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:258:in `load_dependency'
/usr/local/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:286:in `load'
/usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/tasks/database_tasks.rb:233:in `load_schema'
/usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/tasks/database_tasks.rb:255:in `block in load_schema_current'
/usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/tasks/database_tasks.rb:304:in `block in each_current_configuration'
/usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/tasks/database_tasks.rb:303:in `each'
/usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/tasks/database_tasks.rb:303:in `each_current_configuration'
/usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/tasks/database_tasks.rb:254:in `load_schema_current'
/usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/railties/databases.rake:248:in `block (3 levels) in <top (required)>'
/usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/railties/databases.rake:252:in `block (3 levels) in <top (required)>'
/usr/local/bundle/gems/railties-5.1.4/lib/rails/commands/rake/rake_command.rb:21:in `block in perform'
/usr/local/bundle/gems/railties-5.1.4/lib/rails/commands/rake/rake_command.rb:18:in `perform'
/usr/local/bundle/gems/railties-5.1.4/lib/rails/command.rb:46:in `invoke'
/usr/local/bundle/gems/railties-5.1.4/lib/rails/commands.rb:16:in `<top (required)>'
/usr/src/app/bin/rails:9:in `require'
/usr/src/app/bin/rails:9:in `<top (required)>'
/usr/local/bundle/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load'
/usr/local/bundle/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call'
/usr/local/bundle/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call'
/usr/local/bundle/gems/spring-2.0.2/lib/spring/client.rb:30:in `run'
/usr/local/bundle/gems/spring-2.0.2/bin/spring:49:in `<top (required)>'
/usr/local/bundle/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load'
/usr/local/bundle/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>'
/usr/src/app/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
Tasks: TOP => db:schema:load
(See full trace by running task with --trace)
Я не нашел ни одного другого пользователя docker с этой проблемой, и мои коллеги не имеют такой же проблемы вообще. Конечно, они используют другие операционные системы, такие как MA C -OS или Debian .
Каждый раз, когда мне нужны эти функции, мне приходится перезагружать образы или иногда начать с нуля перестройку всей экосистемы docker, которая очень трудоемкая и раздражающая.
конфигурация
Это мой docker -compose.yml файл:
version: '3.5'
services:
web:
build:
context: .
dockerfile: ./docker/web/Dockerfile
container_name: myapp_web
environment:
RAILS_ENV: development
APP_IP: 174.21.0.2
OMNIAUTH_IP: 174.21.1.5
hostname: test.host
volumes:
- ./:/usr/src/app
ports:
- 3000:3000
- 4567:4567
links:
- mysql
# For using pry
stdin_open: true
tty: true
env_file: .env
networks:
net:
ipv4_address: 174.21.0.2
extra_hosts:
- "test.host:174.21.0.2"
- "myapp.host:174.21.0.2"
mysql:
build:
context: .
dockerfile: ./docker/mysql/Dockerfile
container_name: myapp_mysql
env_file: .env
command: [mysqld, --character-set-server=utf8mb4, --collation-server=utf8mb4_unicode_ci]
ports:
- 32788:3306
volumes:
- ./:/usr/src/app
- ./docker/mysql/data:/var/lib/mysql
networks:
net:
ipv4_address: 174.21.0.4
networks:
net:
driver: bridge
ipam:
config:
- subnet: 174.21.1.0/16
name: myapp_dev_net
volumes:
gems:
это мой MySQL Dockerfile:
FROM mysql:5.6
Ожидаемое поведение
Я хочу, чтобы моя реализация docker работала правильно, я не хочу перезапускать свои контейнеры каждые 15 минут, когда мне нужно сделать некоторые изменения в базе данных. Любые предложения приветствуются.
Дополнительные вопросы
Есть ли какая-либо причина, почему это происходит в Ubuntu 18, но не в Debian или MA C -OS? Я фанат Ubuntu, и я хотел бы исправить это в Ubuntu, но если переключение ОС улучшит мой опыт с docker, я сделаю это без вопросов.