【问题标题】:I built an rails environment with Docker, but there is no rails file我用Docker搭建了一个rails环境,但是没有rails文件
【发布时间】:2020-06-11 12:43:50
【问题描述】:

我使用“Docker official rails quickstart”构建了一个环境。没有错误。

终端显示app、bin、db目录已经创建,但是没有。

% docker-compose run web rails new . --force --no-deps --database=postgresql
Starting root_db_1 ... done
       exist  
      create  README.md
      create  Rakefile
      create  .ruby-version
      create  config.ru
      create  .gitignore
       force  Gemfile
         run  git init from "."
Initialized empty Git repository in /myapp/.git/
      create  package.json
      create  app
      create  app/assets/config/manifest.js
      create  app/assets/javascripts/application.js
      create  app/assets/javascripts/cable.js

 ..........
         run  bundle exec spring binstub --all
* bin/rake: Spring inserted
* bin/rails: Spring inserted

%
app-directory% ls
Dockerfile              Gemfile.lock            entrypoint.sh
Gemfile                 docker-compose.yml      src

试了好几次跑

docker-compose run web rails new . --force --no-deps --database=postgresql

但什么都没有改变。

我的 Ruby 版本是 2.6.3,Rails 版本是 6.0.3,我使用的是 MacOS。

我应该怎么做才能解决这个问题?

【问题讨论】:

  • 如果代码显示目录已创建,那么它们已创建,您只是没有找对地方。除了猜测原因和解决方案之外,您还没有告诉我们做任何事情。
  • 此外,SO 在问题、cmets 和答案中对表情符号皱眉。如果它们在代码中或作为字符中的字符是必要的,或者用于讨论代码或字符处理,那么它们可以,但不是在常规文本中。在Meta Stack Overflow 网站上搜索“emoji”以找出共识。
  • 从现在开始,我关心的是使用表情符号。

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


【解决方案1】:

我假设 app-directory 是一个本地目录。 如果是这样,请仔细检查您是否已使用

将本地目录安装到 docker-compose.yml 中的 Web 容器
volumes:
  - .:/myapp

否则文件只会在 docker 容器中创建。

【讨论】:

  • 多亏了您的建议,这个问题已经解决了!谢谢。
猜你喜欢
  • 2014-10-02
  • 1970-01-01
  • 1970-01-01
  • 2010-11-26
  • 1970-01-01
  • 2011-02-08
  • 1970-01-01
  • 2012-01-23
  • 1970-01-01
相关资源
最近更新 更多