【发布时间】:2015-12-19 08:01:44
【问题描述】:
我正在使用 docker-machine、Mac OS X、驱动程序 digitalocean 和默认 virtualbox。
Dockerfile:
FROM ruby:2.2.0
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev
RUN mkdir /myapp-web-api
WORKDIR /myapp-web-api
ADD Gemfile /myapp-web-api/Gemfile
ADD Gemfile.lock /myapp-web-api/Gemfile.lock
RUN bundle install
ADD . /myapp-web-api
docker-compose.yml:
db:
image: postgres
ports:
- "5432:5432"
web:
build: .
command: rails s -p 3000 -b '0.0.0.0'
volumes:
- .:/myapp-web-api
ports:
- "3000:3000"
links:
- db
当我使用本地虚拟盒驱动程序卷映射时很好。但是当我将 env 切换到 digitalocean 时,图像开始出现一些问题。
docker-compose 构建没问题
Boriss-MacBook-myapp-web-api wwtlf$ docker-compose ps
Name Command State Ports
------------------------------------------------------------------
myappwebapi_db_1 /docker-entrypoint.sh postgres Exit 0
myappwebapi_web_1 rails s -p 3000 -b 0.0.0.0 Exit 1
Boriss-MacBook-myapp-web-api wwtlf$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
myappwebapi_web latest 4c95e37708ff 22 minutes ago 927 MB
postgres latest b305a133422a 13 days ago 265.1 MB
ruby 2.2.0 ac90cee00759 10 months ago 774.7 MB
Boriss-MacBook-Pro:myapp-web-api wwtlf$
当我尝试启动容器时:
Boriss-MacBook-Pro:myapp-web-api wwtlf$ docker-compose up
Starting myappwebapi_db_1
Starting myappwebapi_web_1
Attaching to myappwebapi_db_1, myappwebapi_web_1
db_1 | LOG: database system was shut down at 2015-12-19 07:34:21 UTC
db_1 | LOG: MultiXact member wraparound protections are now enabled
db_1 | LOG: database system is ready to accept connections
db_1 | LOG: autovacuum launcher started
web_1 | /usr/local/bundle/gems/bundler-1.7.12/lib/bundler/definition.rb:22:in `build': /myapp-web-api/Gemfile not found (Bundler::GemfileNotFound)
web_1 | from /usr/local/bundle/gems/bundler-1.7.12/lib/bundler.rb:155:in `definition'
web_1 | from /usr/local/bundle/gems/bundler-1.7.12/lib/bundler.rb:118:in `setup'
web_1 | from /usr/local/bundle/gems/bundler-1.7.12/lib/bundler/setup.rb:17:in `<top (required)>'
web_1 | from /usr/local/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `require'
web_1 | from /usr/local/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `rescue in require'
web_1 | from /usr/local/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:39:in `require'
web_1 | from /usr/local/bundle/bin/rails:14:in `<main>'
myappwebapi_web_1 exited with code 1
嗯,让我们检查一下音量:
docker-compose run web /bin/bash
Starting myappwebapi_db_1
root@155e09fc57ac:/myapp-web-api# ls
root@155e09fc57ac:/myapp-web-api#
空:( 让我们尝试另一种方式:
Boriss-MacBook-Pro:myapp-web-api wwtlf$ docker run -i -t myappwebapi_web /bin/bash
root@ee53fea29f97:/myapp-web-api# ls
Dockerfile Gemfile Gemfile.lock README.rdoc Rakefile app bin config config.ru db docker-compose.yml lib log public test tmp vendor
root@ee53fea29f97:/myapp-web-api#
docker-compose run 和 docker run 有什么区别???
看起来我连接到不同图像的线...
更新:
我发现 docker-compose 运行 web /bin/bash 文件夹 /myapp-web-api 已映射到 digitalocean VM 上的 root@myapp-prod:/Users/wwtlf/Projects/MYAPP/myapp-web-api 文件夹,但是不接待。
【问题讨论】:
标签: ruby-on-rails docker digital-ocean docker-compose