Closed alexlenail closed 7 years ago
My mistake, I didn't look closely at the wiki! https://github.com/sosedoff/pgweb/wiki/Docker This mostly answers my question. I'll try to figure the rest out on my own.
Okay, so I added to my docker-compose file the following:
pgweb:
container_name: pgweb
restart: always
image: sosedoff/pgweb
ports:
- "8081:8081"
links:
- postgres:postgres
environment:
- DATABASE_URL=postgres://postgres:postgres@db:5432/postgres
I have my functional postgres db in the same file
With the above, I get:
Connecting to server...
Error: dial tcp: lookup db on 192.168.65.1:53: no such host
If I change the environment line to
- DATABASE_URL=postgres://postgres:postgres@postgres:5432/postgres
I get
Connecting to server...
Error: dial tcp 172.17.0.2:5432: getsockopt: connection refused
I changed the name just in case since my image is called postgres not db, the way you name it on the wiki https://github.com/sosedoff/pgweb/wiki/Docker
Any ideas? What's the correct DATABASE_URL? (I'm assuming that's the issue) @sosedoff
As far as connecting to the postgres (from pgweb) it should just work as long as the postgres server is reachable and credentials are correct (host/port/user/db). From your example its not clear how you start postgres container. Could you provide more details from your compose file?
Hi @sosedoff Here's the postgres piece of the compose file:
postgres:
container_name: postgres
restart: always
image: postgres:latest
volumes:
- ./postgres-data:/var/lib/postgresql/data
ports:
- "5432:5432"
Postgres does not start right away, it takes a few seconds after start to become fully available. Since pgweb depends on the postgres container, you have to specify that in your compose file:
pgweb:
container_name: pgweb
restart: always
image: sosedoff/pgweb
ports:
- "8081:8081"
links:
- postgres:postgres
environment:
- DATABASE_URL=postgres://postgres:postgres@postgres:5432/postgres
depends_on:
- postgres
Also, default postgres container does not have SSL enabled, so just disable that. New variables:
DATABASE_URL=postgres://postgres:postgres@postgres:5432/postgres?sslmode=disable
@sosedoff that worked! Thanks so much!! Would you like to update the wiki or can I?
What would you like to modify in wiki?
Hi @sosedoff I would just add the correct docker-compose config from your last comment to the bottom of that page, just in case there's anyone out there like me who'd like to add this to their docker-compose setup. I personally think that for folks running postgres in a compose setup, plopping in pgweb if they don't already have a tool for looking through their database would be a godsend.
Sure, go ahead.
@sosedoff would you anticipate pgweb to fail if the db were too large? On a small DB, this works fine, but on my production DB I can't get pgweb to load. The log has no errors in it, the page just won't load...
Its hard to just guess, but you can check the request status in the chrome debug tools. Pgweb makes AJAX call for each query so you'll be able to see if anything is being returned at all.
nevermind I'm a moron. =)
Care to share a bit more info on the problem? Its always good to know what kind of stuff people do so i can work out a better ux
The port was closed. "Huh, that's funny, it won't load..." =)
Did the flag (which I have in my docker compose)
environment:
- DATABASE_URL=
stop working or move in a recent version of pgweb?
Hello! This looks terrific. For my use case, I'd love to run this container alongside my postgres container, link them together, and have pgweb available at some port on my URL. Is that an idea that's been had before?