Connect to postgres in 2.0 w/ docker from within image

docker
postgresql

#1

Hello,

version: 2
jobs:
  build-and-test:
    docker:
      - image: docker:17.05.0-ce-git
      - image: postgres:9.6-alpine
    steps:
      - checkout
      - setup_remote_docker

using the configuration above, I build my image and then want to run tests from within the image as in:

docker run -it --net=host \
        -e DATABASE_URL=postgres://postgres:postgres@localhost:5432/dbname \
        -e RAILS_ENV=test \
    my-rails-image bundle exec rake db:create db:schema:load

I was able to do this in 1.0 with the machine executor and provided postgresql service. I’m not sure how to do this on 2.0 with docker executor.

Thanks for the help


#2

Answering my own question but I’ve found out that if I do

docker run -d -p 5432:5432 postgres:9.6-alpine

in a previous step, this works.


#3

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.