Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to create a docker image with Ruby and Postgresql 9.5

pjmuller
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 27, 2016

Hi everyone,

I would love to use docker pipeline but my Ruby on Rails app needs Postgresql 9.5. When using 

 

FROM ruby:2.2.1
RUN apt-get update \
  && apt-get install -y postgresql postgresql-contrib \
  && apt-get install sudo \
  && apt-get clean \
  && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

 

I'm getting the 9.4 version and  adding apt-get to the 9.5 apt-get install -y gives me an error that the package is not found. I've read that adding packages to apt get can be done as 

RUN sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
RUN wget -q https://www.postgresql.org/media/keys/ACCC4CF8.asc -O - | sudo apt-key add -

 

but this doesn't work in the dockerfile

 

Please help

Greetings,

PJ

1 answer

1 vote
Sten Pittet
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 2, 2016

Hi PJ,

Try this and let me know if it works?

FROM ruby:2.2.1 
RUN sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" >> /etc/apt/sources.list.d/pgdg.list' \
  && wget -q https://www.postgresql.org/media/keys/ACCC4CF8.asc -O - | apt-key add - \
  && apt-get update \
  && apt-get install -y postgresql-9.5 postgresql-contrib-9.5 \
  && apt-get install sudo \
  && apt-get clean \
  && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# This Dockerfile doesn't need to have an entrypoint and a command
# as Bitbucket Pipelines will overwrite it with a bash script.

You are already root so you don't need to run commands with sudo. And I found a different way to update the sources from the Docker documentation.

Cheers,

Sten

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, atlassian community, job interviews, interview tips, career advice, interview preparation, job search, interview experiences, hiring process, atlassian careers, community discussion, interview best practices

Interview Tips & Pet Peeves ✍️

Join the discussion on interview best practices and common pitfalls. Share your experiences and learn from others in the Atlassian Community.

Share you experiences!
AUG Leaders

Atlassian Community Events