简体   繁体   English

Docker开发环境拒绝连接

[英]connection refused for Docker development environment

here are my configurations: 这是我的配置:

docker-compose.yml

---
web:
  build: .
  command: RAILS_ENV=production bundle exec rake assets:precompile --trace
  command: foreman start
  ports:
  - "3000:3000"
  links:
    - postgres
  environment:
    - RAILS_ENV=production
    - RACK_ENV=production
    - POSTGRES_DATABASE=postgres
    - POSTGRES_USERNAME=postgres
    - POSTGRES_HOST=db
postgres:
  image: postgres

Procfile

web: bundle exec puma -e _env:RAILS_ENV -C config/puma.rb
nginx: /usr/sbin/nginx -g 'daemon off;'

Dockerfile

# Generated by Cloud66 Starter
FROM ruby:2.2.3

RUN apt-get update -qq && apt-get install -y build-essential
RUN apt-get -y install curl \
              git \
              imagemagick \
              libmagickwand-dev \
              libcurl4-openssl-dev \
              nodejs \
              postgresql-client

# Installing your gems this way caches this step so you dont have to reintall your gems every time you rebuild your image.
# More info on this here: http://ilikestuffblog.com/2014/01/06/how-to-skip-bundle-install-when-deploying-a-rails-app-to-docker/
# Copy the Gemfile and Gemfile.lock into the image.
# Temporarily set the working directory to where they are.
WORKDIR /tmp
ADD Gemfile Gemfile
ADD Gemfile.lock Gemfile.lock
RUN gem install bundler
RUN bundle install

# Install and configure nginx
RUN apt-get install -y nginx
RUN rm -rf /etc/nginx/sites-available/default
ADD config/nginx.conf /etc/nginx/nginx.conf

# Add our source files precompile assets
ENV APP_HOME /app
RUN mkdir -p $APP_HOME
WORKDIR $APP_HOME
ADD . $APP_HOME
# RUN RAILS_ENV=production bundle exec rake assets:precompile --trace

I build docker container with docker-compose and was successful: 我用docker-compose构建docker容器并成功完成了:

docker-compose build

And here is output for docker-compose up 这是docker-compose up输出

docker-compose up

⇒  docker-compose up
Starting watchhound_postgres_1
Starting watchhound_web_1
Attaching to watchhound_postgres_1, watchhound_web_1
postgres_1  | LOG:  database system was interrupted; last known up at 2016-06-24 08:58:25 UTC
postgres_1  | LOG:  database system was not properly shut down; automatic recovery in progress
postgres_1  | LOG:  invalid record length at 0/1707C48
postgres_1  | LOG:  redo is not required
postgres_1  | LOG:  MultiXact member wraparound protections are now enabled
postgres_1  | LOG:  database system is ready to accept connections
postgres_1  | LOG:  autovacuum launcher started
web_1       | 09:04:46 web.1   | started with pid 6
web_1       | 09:04:46 nginx.1 | started with pid 7
web_1       | 09:04:47 web.1   | [6] Puma starting in cluster mode...
web_1       | 09:04:47 web.1   | [6] * Version 3.4.0 (ruby 2.2.3-p173), codename: Owl Bowl Brawl
web_1       | 09:04:47 web.1   | [6] * Min threads: 5, max threads: 5
web_1       | 09:04:47 web.1   | [6] * Environment: _env:RAILS_ENV
web_1       | 09:04:47 web.1   | [6] * Process workers: 1
web_1       | 09:04:47 web.1   | [6] * Phased restart available
web_1       | 09:04:47 web.1   | [6] * Listening on tcp://0.0.0.0:5000
web_1       | 09:04:47 web.1   | [6] * Listening on unix:///var/run/puma.sock
web_1       | 09:04:47 web.1   | [6] Use Ctrl-C to stop
web_1       | 09:04:49 web.1   | [6] - Worker 0 (pid: 12) booted, phase: 0

PROBLEM 问题

Everything looks fine, but when I visit 192.168.99.100:5000 (from docker-machine ip ) the browser says 192.168.99.100 refused to connect 一切看起来都很好,但是当我访问192.168.99.100:5000 (来自docker-machine ip )时,浏览器说192.168.99.100 refused to connect

Not sure what am I missing 不知道我在想什么

我的问题是docker-compose.yml文件,根据我的整体配置,需要绑定端口5000而不是3000

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM