0

這裏是我的配置:連接拒絕了碼頭工人的開發環境

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 

我建立搬運工容器docker-compose和成功:

docker-compose build 

這裏是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 

問題

一切都看起來不錯的輸出,但是當我訪問192.168.99.100:5000(從docker-machine ip )瀏覽器說192.168.99.100 refused to connect

不知道我缺少什麼

回答

0

我的問題是與docker-compose.yml文件,需要綁定端口50003000按我的整體配置。