Skip to content

Create image with empty database #433

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
quanterion opened this issue Apr 20, 2018 · 1 comment
Closed

Create image with empty database #433

quanterion opened this issue Apr 20, 2018 · 1 comment
Labels
question Usability question, not directly related to an error with the image

Comments

@quanterion
Copy link

I'm using docker-compose for testing with one of containers is postgres. Each time I start compose it takes postgres image and spends some to create container out of it because it runs docker-entrypoint.sh.

So I want to speed it up and create Docker image with empty seed database:

FROM postgres:10.1

ENV POSTGRES_PASSWORD mypassword
ENV POSTGRES_DB shell

RUN docker-entrypoint.sh postgres

ENTRYPOINT ["echo DB shell started"]
However it doesn't work because command RUN docker-entrypoint.sh postgres never exits. How to do it the right way?

@wglambert wglambert added the question Usability question, not directly related to an error with the image label Apr 25, 2018
@tianon
Copy link
Member

tianon commented Apr 30, 2018

When you RUN docker-entrypoint.sh postgres, you're literally starting up the PostgreSQL server, which expects to run indefinitely.

As to what you're trying to accomplish, see #375 and #319 (comment). You'll need to set PGDATA, and likely run initdb yourself (because docker-entrypoint.sh's initialization code is tailored for starting up a persistent instance of PostgreSQL, as you've discovered).

In the future, these sorts of questions/requests would be more appropriately posted to the Docker Community Forums, the Docker Community Slack, or Stack Overflow.

@tianon tianon closed this as completed Apr 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Usability question, not directly related to an error with the image
Projects
None yet
Development

No branches or pull requests

3 participants