Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

186
Views
Iniciando Postgres en Docker Container

Para la prueba, estoy tratando de configurar Postgres dentro de un contenedor docker para que nuestra aplicación python pueda ejecutar su conjunto de pruebas en su contra.

Aquí está mi Dockerfile:

 # Set the base image to Ubuntu FROM ubuntu:16.04 # Update the default application repository sources list RUN apt-get update && apt-get install -y \ python2.7 \ python-pip \ python-dev \ build-essential \ libpq-dev \ libsasl2-dev \ libffi-dev \ postgresql USER postgres RUN /etc/init.d/postgresql start && \ psql -c "CREATE USER circle WITH SUPERUSER PASSWORD 'circle';" && \ createdb -O darwin circle_test USER root RUN service postgresql stop && service postgresql start # Upgrade pip RUN pip install --upgrade pip COPY . /app WORKDIR /app RUN pip install -r requirements.txt EXPOSE 5000 # Set the container entrypoint ENTRYPOINT ["gunicorn", "--config", "/app/config/gunicorn.py", "--access-logfile", "-", "--error-logfile", "-", "app:app"]

Cuando corro:

 docker run --entrypoint python darwin:latest -m unittest discover -v -s test

Me estoy poniendo:

 could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432?

La única forma en que puedo hacer que funcione es si hago ssh en el contenedor, reinicio Postgres y ejecuto el conjunto de pruebas directamente.

¿Hay algo que me estoy perdiendo aquí?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

En un Dockerfile tienes

  • una fase de configuración, la directiva RUN (y algunas otras)

  • el (los) proceso (s) que inicia, que pone en cualquiera

CMD

o

ENTRYPOINT

ver los documentos

https://docs.docker.com/engine/reference/builder/#cmd

y

https://docs.docker.com/engine/reference/builder/#entrypoint

cuando un contenedor ha completado lo que tiene que hacer en esta fase de inicio, muere.

Es por eso que la referencia Dockerfile para PostgreSQL, en

https://github.com/docker-library/postgres/blob/3d4e5e9f64124b72aa80f80e2635aff0545988c6/9.6/Dockerfile

termina con

CMD ["postgres"]

si desea iniciar varios procesos, consulte supervisord o una herramienta similar (s6, daemontools...)

https://docs.docker.com/engine/admin/using_supervisord/

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!