Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

299
Vistas
Connect rails app in Docker container to external Postgresql Database via URL

I have a docker container with web rails app. Also I have external database on my osx machine. If I exec on osx:

psql "postgres://postgres:testing@0.0.0.0:5432/movies_development"

I run okay

If I run it in container I'll receive

psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

Have any ideas how to connect to external database from container? thanks

about 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

I found a way for connect app in docker container to local database which located on my osx.

0.0.0.0:5432 is an localhost address of container (not a localhost of osx) and we must set new one:

  1. Find osx Ip local address in Preferences > Network Settings (my was 192.168.0.102)
  2. Add this Ip to line listener_address: '192.168.0.102, localhost' of postgresql config file.
  3. Add extra line with Ip 192.168.0.102, host and md5 to pg_hba.conf file
  4. Restart Postgresql

Set connection settings in app via ENV like: postgres://postgres:testing@192.168.0.102:5432/movies_development

about 4 years ago · Santiago Trujillo Denunciar

0

There may be two reasons as per your question :

  • Have you exposed EXPOSE 5432 during your docker image build ? or before starting container with docker run -it -d --name $container_name -p 5432:5432 $image_name ? If NO than you must have to do any of above changes than and than it can connect to externally hosted database.
  • If your are going inside your docker container with docker exec -it $container_name bash and executing command this psql "postgres://postgres:testing@0.0.0.0:5432/movies_development" then there must be psql client installed in your docker container with proper $PATH variable otherwise it will throw error like command not found/no such file or directory.
  • Note: if your application is using some other way to communicate with database than your application will work without psql client program.

Hope this help.Thank you!

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda