gpt4 book ai didi

ruby-on-rails - 在Docker上 pry 无法正常工作

转载 作者:行者123 更新时间:2023-12-02 20:07:35 28 4
gpt4 key购买 nike

我尝试了在tty: true stdin_open: true内使用docker-compose.yml并将其附加到容器ID(在http://www.chris-kelly.net/2016/07/25/debugging-rails-with-pry-within-a-docker-container/之后)的方法,但是它只是挂了。

我还在本文https://blog.carbonfive.com/2015/03/17/docker-rails-docker-compose-together-in-your-development-workflow/之后尝试了docker-compose run --service-ports web,但是当binding.pry时,它也挂起了请求
supervisord会影响吗?

这是Dockerfile:

FROM ruby:2.3.3

RUN apt-get update -qq && apt-get install -y build-essential libpq-dev supervisor
RUN curl -sL https://deb.nodesource.com/setup_9.x | bash - && apt-get install -yq nodejs
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN apt-get update && apt-get install yarn


RUN mkdir /example
WORKDIR /example
COPY Gemfile /example/Gemfile
COPY Gemfile.lock /example/Gemfile.lock

RUN bundle install

COPY . /example
COPY docker/supervisor.conf /etc/supervisor/conf.d/example.conf

RUN cd client-app && npm install

CMD supervisord -n

docker-compose.yml:
version: '3'
services:
db:
image: postgres
web:
build: .
environment:
API_HOST: http://localhost:3000/api
volumes:
- .:/example
ports:
- "3000:3000"
- "4200:4200"
depends_on:
- db

supervisor.conf:
[program:rails]
directory=/example
command=rails server -b 0.0.0.0 -p 3000
autostart=true
autorestart=true

[program:npm]
directory=/example
command=/bin/bash -c "yarn && cd client-app && npm run docker-start"
autostart=true
autorestart=true

最佳答案

(假设您正在运行诸如docker run -d --name=postgres ...之类的postgres)

我会放弃写作并尝试

docker build -t web .
docker run --link postgres:db -it -p 3000:3000 -p 4200:4200 web

如果失败了,我会平底锅
docker run --link postgres:db -it -p 3000:3000 -p 4200:4200 web bash

然后尝试在容器内手动运行 rails srails c等。

关于ruby-on-rails - 在Docker上 pry 无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48766477/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com