【发布时间】:2019-03-13 19:50:10
【问题描述】:
我正在学习本教程:
https://docs.docker.com/compose/rails/
我想使用 PostgreSQL 数据库(Dockerized)创建一个 Ruby On Rails API
但是当我运行时
docker-compose run web rails new . --force --no-deps --api --database=postgresql
我明白了:
Creating soft-vape-db ... done
/usr/bin/entrypoint.sh: line 8: exec: @: not found
入口点.sh
#!/usr/bin/env bash
set -e
rm -f /myapp/tmp/pids/server.pid
exec "$@"
Dockerfile
FROM ruby:2.5
RUN apt-get update -qq && apt-get install -y nodejs postgresql-client
RUN 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"]
docker-compose.yml
version: '3'
services:
db:
container_name: soft-vape-db
image: postgres
volumes:
- ./tmp/db:/var/lib/postgresql/data
web:
container_name: soft-vape-api
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
有什么想法吗?
【问题讨论】:
-
我会在本地运行
rails new,并在将 Docker 引入之前尝试让您的应用程序正常工作。在 Docker 中将其打包为 最后 步骤,而不是第一步。 -
试着去掉引号。使用
exec $@。 -
嗯?当您的文件有 4 行时,您的错误状态如何“错误...第 8 行”?您确定该错误仍然与您在此处显示的代码相关吗?
-
我刚刚删除了文件的 cmets ;) 但它是针对这一行的。
-
我仍然有错误@kichik 没有引号:s /usr/bin/entrypoint.sh: line 8: exec: @: not found
标签: ruby-on-rails docker docker-compose docker-entrypoint