Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@brylor
Created July 19, 2016 21:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brylor/e3bc2b0192de9571aff01b6ab08bf46c to your computer and use it in GitHub Desktop.
Save brylor/e3bc2b0192de9571aff01b6ab08bf46c to your computer and use it in GitHub Desktop.
E, [2016-07-19T21:14:51.579333 #7] ERROR -- : PG::ConnectionBad: could not translate host name "db" to address: Name or service not known
(Sequel::DatabaseConnectionError)
version: '2'
services:
db:
build: ./postgres
bot:
build: .
command: /app/runbot.sh
volumes:
- .:/app
links:
- "db:database"
depends_on:
- db
FROM ruby:2.3.1
COPY . /app/
RUN gem install bundler --no-ri --no-rdoc && \
cd /app; bundle install --without development test
RUN apt-get update && apt-get -y install vim sqlite3
RUN chown -R nobody:nogroup /app
USER nobody
EXPOSE 9292
WORKDIR /app
RUN /app/runbot.sh
FROM postgres
COPY init.sql /docker-entrypoint-initdb.d/
RUN /etc/init.d/postgresql start
@CzechJiri
Copy link

CzechJiri commented Jul 19, 2016

from the docs

Containers for the linked service will be reachable at a hostname identical to the alias, or the service name if no alias was specified.

  1. I use links only (no alias)
  2. add expose or port 5432
  3. you need to add startup loop to the app (depends_on means depends on service, not postgres being up and ready) https://gist.github.com/CzechJiri/29c9862393c6a9d4435a2bfd50cf546d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment