相关疑难解决方法(0)

使用dockers在nodeJS上为Postgres进行ECONNREFUSED

我正在构建一个使用postgresql在NodeJS上运行的应用程序.我正在使用SequelizeJS作为ORM.为了避免使用真正的postgres守护进程并在我自己的设备上安装nodejs,我正在使用带有docker-compose的容器.

当我运行docker-compose up 它时启动pg数据库

database system is ready to accept connections
Run Code Online (Sandbox Code Playgroud)

和nodejs服务器.但是服务器无法连接到数据库.

Error: connect ECONNREFUSED 127.0.01:5432
Run Code Online (Sandbox Code Playgroud)

如果我尝试在不使用容器的情况下运行服务器(在我的机器上使用真正的nodejs和postgresd)它可以工作.

但我希望它与容​​器一起正常工作.我不明白我做错了什么.

这是docker-compose.yml文件

web:
  image: node
  command: npm start
  ports:
    - "8000:4242"
  links:
    - db
  working_dir: /src
  environment:
    SEQ_DB: mydatabase
    SEQ_USER: username
    SEQ_PW: pgpassword
    PORT: 4242
    DATABASE_URL: postgres://username:pgpassword@127.0.0.1:5432/mydatabase
  volumes:
    - ./:/src
db:
  image: postgres
  ports:
  - "5432:5432"
  environment:
    POSTGRES_USER: username
    POSTGRES_PASSWORD: pgpassword
Run Code Online (Sandbox Code Playgroud)

有人可以帮帮我吗?

(喜欢泊船的人:))

postgresql node.js sequelize.js docker

31
推荐指数
4
解决办法
3万
查看次数

mongodb连接拒绝了docker-compose

dockerfile包括: -

FROM ruby:2.2.3-slim

MAINTAINER Milan Rawal <milan@gmail.com>

RUN apt-get update && apt-get install -qq -y build-essential nodejs libmagickcore-dev imagemagick libmagickwand-dev libxml2-dev libxslt1-dev git-core curl htop --fix-missing --no-install-recommends

ENV INSTALL_PATH /air_scout
RUN mkdir -p $INSTALL_PATH

WORKDIR $INSTALL_PATH

COPY Gemfile Gemfile
RUN bundle install

COPY . .

RUN bundle exec rake RAILS_ENV=production   SECRET_TOKEN=f6801f0744ff2e86b0baa542fc55075b5b79c922c518e34484cfe6a6c2149510973fa6c90d36c05907f8bf9114b6b33594f3630810b332ef3717b8b8f4f04b1f assets:precompile

VOLUME ["$INSTALL_PATH/public"]

CMD bundle exec unicorn -c config/unicorn.rb  
Run Code Online (Sandbox Code Playgroud)

docker-compose.yml文件包含: -

version: '2'
services:
  mongodb:
    image: mongo:latest
    ports:
      - '27017:27017'
    volumes:
      - air_scout-mongodb:/data/db
  redis:
    image: redis:3.0.5
    ports:
  - …
Run Code Online (Sandbox Code Playgroud)

docker ruby-on-rails-4.2 docker-compose docker-machine

6
推荐指数
1
解决办法
6001
查看次数

如何从docker-compose连接到Host PostgreSQL?

我有一台安装了PostgreSQL的服务器.我的所有服务都在容器中工作(docker-compose).我想从容器中使用我的Host PostgreSQL.买我有错误:

  Unable to obtain Jdbc connection from DataSource (jdbc:postgresql://localhost:5432/shop-bd) for user 'shop-bd-user': Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
  ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  SQL State  : 08001
  Error Code : 0
  Message    : Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.

  Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster …
Run Code Online (Sandbox Code Playgroud)

postgresql networking localhost docker docker-compose

1
推荐指数
2
解决办法
5727
查看次数