Docker上的Rails项目

时间:2016-10-04 16:08:01

标签: ruby-on-rails bash docker docker-compose

我使用Docker来运行Rails项目,但它永远不能运行,我很难过。 这是start_up.sh:

#!/usr/bin/env bash
docker rm $(docker ps -a -q)
docker rmi $(docker images -q -f dangling=true)
docker-compose -f docker-compose.dev.yml build
docker-compose -f docker-compose.dev.yml up

和docker-compose.dev.yml:

redis:
 image: daocloud.io/daocloud/dao-redis:master-init
 environment:
  - REDIS_PASS=**None**
 ports:
   - "6379:6379"
 web:
  build: .
  dockerfile: Dockerfile_dev
  environment:
   - REDIS_HOST=redis
  command: /bin/bash docker_web_run.dev.sh
  volumes:
    - /Users/skio_boss:/rails_app
  ports:
    - "3000:3000"
    - "10022:22"
  links:
    - redis

和Dockerfile_dev:

FROM daocloud.io/skio_dep/rails_4.2.6:v1_onbuild

#set ssh password
RUN echo "root:123456" | chpasswd

ENV RACK_ENV development
# redis
ENV REDIS_HOST redis

# CMD sh docker_web_run.dev.sh

和docker_web_run.dev.sh:

#!/bin/bash
source ~/.bashrc
/usr/sbin/sshd
/etc/init.d/cron start
bundle exec rake db:migrate

#whenever -w
#echo `bundle exec rails s -b 0.0.0.0 -p 3000`
passenger start --environment development --port 3000

然后环境是:

ubuntu 16.04,Docker版本1.12.1 当我跑:$ ./start_up.sh 容器构建成功

Successfully built 628dbf7ff242
Creating skioboss_redis_1
Creating skioboss_web_1
Attaching to skioboss_redis_1, skioboss_web_1

skioboss_web_1没有运行,错误是:

web_1    | /bin/bash: docker_web_run.dev.sh: No such file or directory
skioboss_web_1 exited with code 127

当我用我的手而不是docker_web_run.dev.sh脚本运行skioboss_web_1时,脚本文件就在那里(/rails_app/docker_web_run.dev.sh) 谁能帮我?

1 个答案:

答案 0 :(得分:0)

我找到了解决问题的答案: 卷,我不关心它,当我建立到/ Users目录的链接时,它是好的。 的卷:      - / Users / skio_boss:/ rails_app