ruby-on-rails - 在 Docker 容器上设置 Rails 控制台不接受任何输入
问题描述
我试图在我的 dockerized 容器中设置 Rails 控制台。整个应用程序有多个组件,我已经使用docker-compose
. 这是我docker-compose.yml
文件中的相关服务。
app:
image: <image_name>
# mount the current directory (on the host) to /usr/src/app on the container, any changes in either would be reflected in both the host and the container
tty: true
volumes:
- .:/usr/src/app
# expose application on localhost:36081
ports:
- "36081:36081"
# application restarts if stops for any reason - required for the container to restart when the application fails to start due to the database containers not being ready
restart: always
depends_on:
- other-db
# the environment variables are used in docker/config/env_config.rb to connect to different database containers
container_name: application
environment:
- CONSOLE=$CONSOLE
我Dockerfile
有以下命令ENTRYPOINT /usr/src/app/docker-entrypoint.sh
而在docker-entrypoint.sh
#!/bin/bash
echo "waiting for all db connections to be healthy... Sleeping..."
sleep 1m
mkdir -p /usr/src/app/tmp/pids/
mkdir -p /usr/src/app/tmp/sockets/
if [ "$CONSOLE" = "Y" ];
then
echo "Starting Padrino console"
bundle exec padrino console
fi
当我跑
export CONSOLE=Y
docker-compose -f docker-compose.yml up -d && docker attach application
控制台启动,我看到了,>>
但我无法输入。我哪里错了?
解决方案
尝试使用-i
模式启动容器。
-i, --interactive 附加容器的标准输入
就像是
docker-compose -f docker-compose.yml up -i && docker attach application
您也可以根据需要-d
混合使用。-i
推荐阅读
- unreal-engine4 - 如何在演员虚幻引擎 4 上添加两个脚本
- java - 如何让按钮在 JavaFX 中重叠图像?
- amazon-ecs - 如何使用 Route53 DNS 将 AWS Fargate ECS 容器公开到 Internet?
- reactjs - 点击 Gatsby 中的链接后,整个网站都卡住了
- angular - 带有数组的行为主题
- r - 按组计算数据帧中的频率
- python - SQL Server Python ML 服务中的 FileNotFoundError
- asp.net-core - ASP.net Core,使用另一个方法的错误消息重定向到 Index 方法
- netsuite - Netsuite - 将包装尺寸添加到标记订单包装屏幕
- excel - 更改依赖单元格中的值时没有 debug.print 输出 [VBA]