Tag: postgresql

连接到Docker容器上的PostgreSQL数据库

我想在不同的Docker容器上运行一个PostgreSQL数据库和一个由Django支持的REST API的应用程序。 到目前为止,API已经在连接到SQLite数据库的Docker上运行,但是现在我遇到了麻烦,我想连接到PostgreSQL数据库。 Docker的docker-compose.yml文件: version: '2' services: postgres: image: postgres api: build: . command: bash -c "python manage.py migrate && python manage.py runserver 0.0.0.0:1337" volumes: – .:/usr/src/app ports: – "1337:1337" depends_on: – postgres Django的settings.py (根据文档使用基本postgres映像的默认设置): DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': 'wgomanager', 'USER': 'postgres', 'PASSWORD': 'mysecretpassword', 'HOST': 'localhost', 'PORT': '5432', } } 当我用docker-compose […]

`初始化':schemepostgres不接受registry部分:postgres:@(或坏主机名?)(URI :: InvalidURIError)与docker

我正在使用与Postgres DB Docker容器连接的Rails。 它看起来像我越来越错误,当我运行rails c : /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/uri/generic.rb:204:in `initialize': the scheme postgres does not accept registry part: postgres:@ (or bad hostname?) (URI::InvalidURIError) 有没有原因,这是行不通的? 我的database.yml是: production: <<: *default url: <%= ENV['DATABASE_URL'] %> 已定义$DATABASE_URL 有意思的是,直到昨天还在工作了几天,今天又停止了工作。 下面是Rails 4.2.1生成的! # As with config/secrets.yml, you never want to store sensitive information, # like your database password, in your source code. If […]

指定Docker容器的超级用户PostgreSQL密码

在Docker容器中运行PostgreSQL数据库时,官方PostgreSQL Docker Image的文档指定应将pipe理员密码设置为环境variables,如: docker run –name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -d postgres 对于那些不想在脚本中硬编码纯文本密码的人,是否有更安全的select要考虑?

docker-compose不启动postgres图像

我正在创build一个Django应用程序的docker-composeconfiguration,Dockerfile的构build成功,但是当我编写它们时,django返回一个问题 – 无法连接到posgres。 我运行docker-compose run web bash ,发现redis和posgres都无法连接。 我的docker-compose.yml文件: db: image: postgres:9.1 environment: – POSTGRES_PASSWORD=mysecretpassword redis: image: redis:2.8 web: links: – db – redis build: . volumes: – .:/workspace ports: – "8000:8000“ command: python /workspace/BreadTripServer/webapps/manage.py runserver 0.0.0.0:8000 –settings=configs.local_default 错误信息,当我做docker-compose up : sudo docker-compose up Recreating breadtrip_db_1… Recreating breadtrip_redis_1… Recreating breadtrip_web_1… Attaching to breadtrip_redis_1, breadtrip_web_1 redis_1 […]

我应该如何使用Postgresql泊坞窗图像/容器?

我是docker工人。 我仍然试图把我的头围绕这一切。 我正在构build一个节点应用程序(REST api),使用Postgresql来存储我的数据。 我已经花了几天的时间了解了docker工人,但是我不确定自己是否按照我应有的方式做事。 所以这是我的问题: 我使用的官方dockerpostgres 9.5图像作为基础来build立自己的(我的Dockerfile只在其上添加plpython,并安装一个自定义的python模块,以便在plpython存储过程中使用)。 我创build了我的容器作为由postgres图像文档suggedsted: docker运行 – 名称some-postgres -e POSTGRES_PASSWORD = mysecretpassword -d postgres 在停止容器后,我无法使用上述命令再次运行它,因为容器已经存在。 所以我使用docker start而不是docker run来启动它。 这是做事情的正常方式吗? 我通常会第一次使用docker运行,docker会每隔一段时间启动一次? 坚持:我创build了一个数据库,并将其填充到正在运行的容器中。 我使用pgadmin3来连接。 我可以停止并启动容器,数据仍然存在,但我不确定这是怎么发生的。 我可以在官方postgres映像的Dockerfile中看到卷被创build(VOLUME / var / lib / postgresql / data),但我不确定这是持久性工作的原因。 请您简单介绍一下(或者指出一个解释)这一切是如何运作的? 架构:从我读到的,似乎这种应用程序最合适的架构将运行3个独立的容器。 一个用于数据库,一个用于保存数据库数据,另一个用于节点应用程序。 这是一个好办法吗? 如何使用数据容器改善事情? AFAIK我目前的设置工作正常,没有一个。 还有什么我应该注意的吗? 谢谢 编辑︰join我的困惑,我只是从debian官方图像(没有Dockerfile,只是docker运行-i -t -d – 名称debtest debian / bin / bash)运行一个新的容器。 随着容器在后台运行,我使用docker […]

连接到AWS实例上承载的Docker容器上的远程数据库

我有一个运行在Docker容器上的PostgreSQL数据库,IP_container容器的IP地址,并公开了端口5432,托pipe在AWS IP实例IP_instance上。 我的安全组允许端口5432上的所有TCP连接。 我无法使用IP_instance和端口5432从本地计算机上连接数据库(无法find主机)。 我错过了什么吗?

Docker – PG :: ConnectionBad

用Phusion Passenger运行Rails,目前遇到postgres问题,每当我运行构build命令时,我得到这个错误: PG::ConnectionBad (could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"? ): 我的Dockerfile FROM phusion/passenger-customizable MAINTAINER VodkaMD <support@nyvur.com> ENV RACK_ENV="production" RAILS_ENV="production" SECRET_KEY_BASE="e09afa8b753cb175bcef7eb5f737accd02a4c16d9b6e5d475943605abd4277cdf47c488812d21d9c7117efd489d876f34be52f7ef7e88b21759a079339b198ce" ENV HOME /root CMD ["/sbin/my_init"] RUN /pd_build/utilities.sh RUN /pd_build/ruby2.2.sh RUN /pd_build/python.sh RUN /pd_build/nodejs.sh # Custom instructions RUN apt-get […]

Django无法在Docker安装中连接到Postgres

我在使用Django和Postgres的Docker中设置了一个应用程序。 我无法从应用程序连接到Postgres。 当我运行: docker-compose run web python manage.py runserver docker-compose run web python manage.py migrate 我得到以下错误: django.db.utils.OperationalError: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"? 这是我的Dockerfile: FROM python:2.7 ADD requirements.txt /app/requirements.txt WORKDIR /app/ RUN pip install -r requirements.txt 我的docker-compose.yml: version: […]

如何将容器ip作为ENV传递给docker-compose文件中的其他容器

这是我的docker-compose文件: version: '3.0' services: app-web: restart: always build: ./web environment: PG_HOST: $(APP_DB_IP) PG_PORT: 5432 ports: – "8081:8080" links: – app-db app-db: build: ./db expose: – "5432" volumes: – /var/lib/postgresql/data 我想通过应用程序的Web应用程序数据库(在这种情况下Postgresql)的IP作为ENV VAR,所以它可以连接到数据库顺利…任何想法如何实现它?

Docker错误:standard_init_linux.go:185:exec用户进程导致“没有这样的文件或目录”

我试图用postgresql数据库设置我的elixir-phoenix应用程序来运行Docker。 这是我的Dockerfile的样子: # ./Dockerfile # Starting from the official Elixir 1.5.2 image: # https://hub.docker.com/_/elixir/ FROM elixir:1.5.2 ENV DEBIAN_FRONTEND=noninteractive # Install hex RUN mix local.hex # Install rebar RUN mix local.rebar # Install the Phoenix framework itself RUN mix archive.install https://github.com/phoenixframework/archives/raw/master/phx_new.ez # Install NodeJS 6.x and the NPM RUN curl -sL https://deb.nodesource.com/setup_6.x | bash – RUN […]