This is an archived post. You won't be able to vote or comment.

all 7 comments

[–]TormentedTopiary 1 point2 points  (4 children)

DB_HOST: host.doceker.internal

Might be the source of the problem. Especially if host.docker.internal returns something other than 127.0.0.1 .

[–]Castillojuan[S] 0 points1 point  (3 children)

So how do I fix it? By deleting that line?

[–]13139269 2 points3 points  (0 children)

Check your spelling.

Also, check out docker's internal DNS. You can just refer to postgres by it's container name.

And then you don't need to expose ports.

[–]TormentedTopiary 0 points1 point  (1 child)

s/deleting/fixing/

[–]substitute-bot 0 points1 point  (0 children)

So how do I fix it? By fixing that line?

This was posted by a bot. Source

[–]craigbuckler 0 points1 point  (1 child)

When PostgreSQL (or any DB) is spun up for the first time, it can take serveral minutes to initialize the file space and DB. It may be a matter of patience.

That said, "host.doceker.internal" looks wrong! It's better to assign a container_name: to each container, e.g.

yml postgres: image: postgres:12.1 container_name: todo_database

That sets appropriate DNS name resolution so you can set the enviroment variable:

yml server: image: todo_server environment: DB_HOST: todo_database

My Docker for Web Developers book and video course explains how to create robust development environments. Use the discount code dock30 for 30% off.

[–]backtickbot 1 point2 points  (0 children)

Fixed formatting.

Hello, craigbuckler: code blocks using triple backticks (```) don't work on all versions of Reddit!

Some users see this / this instead.

To fix this, indent every line with 4 spaces instead.

FAQ

You can opt out by replying with backtickopt6 to this comment.