I use Docker in my Rails app. Now I try do build it on new machine and suffer some problems.
When I run docker-compose -f dcom-dev.yml run --user $(id -u) web bundle install
it starts to work, but failes with
An error occurred while installing debug_inspector (0.0.2), and Bundler cannot continue.
Make sure that `gem install debug_inspector -v '0.0.2'` succeeds before bundling.
If I try docker-compose -f dcom-dev.yml run --user $(id -u) web gem install debug_inspector -v '0.0.2'
it successfully executes, telling that gem's intalled.
Also during installing bundle produces terrible output like:
Errno::EACCES: Permission denied @ rb_sysopen - /bundler_cache/extensions/x86_64-linux/2.3.0-static/pg-0.18.4/gem_make.out
or
sudo: unknown uid 1000: who are you?
whoami
runs without any problems, so I don't know, why it asks me so strange questions :)
dcom-dev.yml
:
version: '2'
services:
db:
image: postgres
volumes_from:
- db_data
nginx:
build:
context: ./service/nginx
ports:
- "1935:1935"
- "80:80"
depends_on:
- web
volumes_from:
- records
processor:
build:
context: ./service/processor
ports:
- "3322:22"
volumes_from:
- records
web: &app_base
build: .
command: bundle exec rails s -p 3000 -b '0.0.0.0'
volumes_from:
- bundler_cache
volumes:
- .:/app
ports:
- "3000:3000"
depends_on:
- db
- processor
env_file: .env
worker:
<<: *app_base
ports: []
command: bundle exec rake jobs:work
db_data:
image: busybox
volumes:
- /var/lib/postgresql/data
records:
image: busybox
volumes:
- /records
bundler_cache:
image: busybox
volumes:
- /bundler_cache
Part of Dockerfile
that's about ruby:
FROM buildpack-deps:trusty
# Ruby
# skip installing gem documentation
RUN mkdir -p /usr/local/etc \
&& { \
echo 'install: --no-document'; \
echo 'update: --no-document'; \
} >> /usr/local/etc/gemrc
ENV RUBY_MAJOR 2.3
ENV RUBY_VERSION 2.3.1
ENV RUBY_DOWNLOAD_SHA256 b87c738cb2032bf4920fef8e3864dc5cf8eae9d89d8d523ce0236945c5797dcd
ENV RUBYGEMS_VERSION 2.6.6
# some of ruby's build scripts are written in ruby
# we purge this later to make sure our final image uses what we just built
RUN set -ex \
&& buildDeps=' \
bison \
libgdbm-dev \
ruby \
' \
&& apt-get update \
&& apt-get install -y --no-install-recommends $buildDeps \
&& rm -rf /var/lib/apt/lists/* \
&& curl -fSL -o ruby.tar.gz "http://cache.ruby-lang.org/pub/ruby/$RUBY_MAJOR/ruby-$RUBY_VERSION.tar.gz" \
&& echo "$RUBY_DOWNLOAD_SHA256 *ruby.tar.gz" | sha256sum -c - \
&& mkdir -p /usr/src/ruby \
&& tar -xzf ruby.tar.gz -C /usr/src/ruby --strip-components=1 \
&& rm ruby.tar.gz \
&& cd /usr/src/ruby \
&& { echo '#define ENABLE_PATH_CHECK 0'; echo; cat file.c; } > file.c.new && mv file.c.new file.c \
&& autoconf \
&& ./configure --disable-install-doc \
&& make -j"$(nproc)" \
&& make install \
&& apt-get purge -y --auto-remove $buildDeps \
&& gem update --system $RUBYGEMS_VERSION \
&& rm -r /usr/src/ruby
ENV BUNDLER_VERSION 1.12.5
RUN gem install bundler --version "$BUNDLER_VERSION"
# install things globally, for great justice
# and don't create ".bundle" in all our apps
ENV GEM_HOME /usr/local/bundle
ENV BUNDLE_PATH="$GEM_HOME" \
BUNDLE_BIN="$GEM_HOME/bin" \
BUNDLE_SILENCE_ROOT_WARNING=1 \
BUNDLE_APP_CONFIG="$GEM_HOME"
ENV PATH $BUNDLE_BIN:$PATH
RUN mkdir -p "$GEM_HOME" "$BUNDLE_BIN" \
&& chmod 777 "$GEM_HOME" "$BUNDLE_BIN"
===============Upd 1================
Here's output for bundle instal --verbose
Errno::EACCES: Permission denied @ rb_sysopen - /bundler_cache/extensions/x86_64-linux/2.3.0-static/debug_inspector-0.0.2/gem_make.out
/usr/local/lib/ruby/2.3.0/open-uri.rb:37:in `initialize'
/usr/local/lib/ruby/2.3.0/open-uri.rb:37:in `open'
/usr/local/lib/ruby/2.3.0/open-uri.rb:37:in `open'
/usr/local/lib/ruby/site_ruby/2.3.0/rubygems/ext/builder.rb:215:in `write_gem_make_out'
/usr/local/lib/ruby/site_ruby/2.3.0/rubygems/ext/builder.rb:135:in `build_error'
/usr/local/lib/ruby/site_ruby/2.3.0/rubygems/ext/builder.rb:174:in `rescue in build_extension'
/usr/local/lib/ruby/site_ruby/2.3.0/rubygems/ext/builder.rb:159:in `build_extension'
/usr/local/lib/ruby/site_ruby/2.3.0/rubygems/ext/builder.rb:201:in `block in build_extensions'
/usr/local/lib/ruby/site_ruby/2.3.0/rubygems/ext/builder.rb:198:in `each'
/usr/local/lib/ruby/site_ruby/2.3.0/rubygems/ext/builder.rb:198:in `build_extensions'
/usr/local/lib/ruby/site_ruby/2.3.0/rubygems/installer.rb:747:in `build_extensions'
/usr/local/lib/ruby/site_ruby/2.3.0/rubygems/installer.rb:299:in `install'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/source/rubygems.rb:143:in `block in install'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/rubygems_integration.rb:169:in `preserve_paths'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/source/rubygems.rb:135:in `install'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/installer/gem_installer.rb:57:in `install'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/installer/gem_installer.rb:15:in `install_from_spec'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/installer/parallel_installer.rb:91:in `block in worker_pool'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/worker.rb:65:in `apply_func'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/worker.rb:60:in `block in process_queue'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/worker.rb:57:in `loop'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/worker.rb:57:in `process_queue'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/worker.rb:29:in `block (2 levels) in initialize'
I can see it tries to use ruby 2.3.0 while my Gemfile specified with 2.3.1. Usually it says smth about it, but now keeps silent.
What can be the problem with all this? And what should I do? Thanks!
==========Upd 2================== I've realised it could be better if I run command without --user $(id -u)
, so I run docker-compose -f dcom-dev.yml run web bundle install
, and it gives me such output:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /bundler_cache/gems/nokogiri-1.6.7.2/ext/nokogiri
/usr/local/bin/ruby -r ./siteconf20160904-1-1ej0stt.rb extconf.rb
Cannot allocate memory - /usr/local/bin/ruby -r ./siteconf20160904-1-1ej0stt.rb extconf.rb 2>&1
Gem files will remain installed in /bundler_cache/gems/nokogiri-1.6.7.2 for inspection.
Results logged to /bundler_cache/extensions/x86_64-linux/2.3.0-static/nokogiri-1.6.7.2/gem_make.out
/usr/local/lib/ruby/site_ruby/2.3.0/rubygems/ext/builder.rb:76:in ``'
/usr/local/lib/ruby/site_ruby/2.3.0/rubygems/ext/builder.rb:76:in `run'
/usr/local/lib/ruby/site_ruby/2.3.0/rubygems/ext/ext_conf_builder.rb:48:in `block in build'
/usr/local/lib/ruby/2.3.0/tempfile.rb:295:in `open'
/usr/local/lib/ruby/site_ruby/2.3.0/rubygems/ext/ext_conf_builder.rb:31:in `build'
/usr/local/lib/ruby/site_ruby/2.3.0/rubygems/ext/builder.rb:164:in `block (2 levels) in build_extension'
/usr/local/lib/ruby/site_ruby/2.3.0/rubygems/ext/builder.rb:163:in `chdir'
/usr/local/lib/ruby/site_ruby/2.3.0/rubygems/ext/builder.rb:163:in `block in build_extension'
/usr/local/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
/usr/local/lib/ruby/site_ruby/2.3.0/rubygems/ext/builder.rb:162:in `build_extension'
/usr/local/lib/ruby/site_ruby/2.3.0/rubygems/ext/builder.rb:201:in `block in build_extensions'
/usr/local/lib/ruby/site_ruby/2.3.0/rubygems/ext/builder.rb:198:in `each'
/usr/local/lib/ruby/site_ruby/2.3.0/rubygems/ext/builder.rb:198:in `build_extensions'
/usr/local/lib/ruby/site_ruby/2.3.0/rubygems/installer.rb:747:in `build_extensions'
/usr/local/lib/ruby/site_ruby/2.3.0/rubygems/installer.rb:299:in `install'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/source/rubygems.rb:143:in `block in install'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/rubygems_integration.rb:169:in `preserve_paths'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/source/rubygems.rb:135:in `install'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/installer/gem_installer.rb:57:in `install'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/installer/gem_installer.rb:15:in `install_from_spec'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/installer/parallel_installer.rb:91:in `block in worker_pool'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/worker.rb:65:in `apply_func'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/worker.rb:60:in `block in process_queue'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/worker.rb:57:in `loop'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/worker.rb:57:in `process_queue'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/worker.rb:29:in `block (2 levels) in initialize'
An error occurred while installing debug_inspector (0.0.2), and Bundler cannot
continue.
Make sure that `gem install debug_inspector -v '0.0.2'` succeeds before
bundling.
Obviously, gem install debug_inspector -v '0.0.2'
succeeds. Also I don't know, if I should use --user
or not. If not, I run bundler as sudo and that's bad, if I use, user has no permissions to write to bundler folder.
Got it! Since I use a droplet on DigitalOcean, I managed to find an error Cannot allocate memory
means I need to create a swap. That really helped.
The issue is here
Your user id is different on your new machine and it appears you've hardcoded this user id into your image, at least in the form of file permissions. The flag --user $(id -u)
tells docker-compose
to run your container as the user on your host, 1000 on your new machine, and that uid does not have access to the files you've created inside your image.
For a more complete answer, we'd need to know about the contents of your dcom-dev.yml and any Dockerfile's you've used to build your images.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.