sosedoff / pgweb

Cross-platform client for PostgreSQL databases
https://sosedoff.github.io/pgweb
MIT License
8.63k stars 732 forks source link

Trying to pull the docker image fails.... #372

Closed natiki closed 6 years ago

natiki commented 6 years ago

Hi,

image

What am I missing here?

sosedoff commented 6 years ago

No idea, the pgweb image is public so it should work. What version of docker are you running? Also, try docker login with your docker user and see if that works.

natiki commented 6 years ago

I logged in and was then able to pull. Strange. Anyway I am now trying to use the docker image to connect to a CockroachDB instance (see here for details) running outside of Docker.

So how to I modify the example given in your instructions to link to the cluster?

sosedoff commented 6 years ago

I think you can start the container with --network=host so pgweb can talk to locally running server.

natiki commented 6 years ago
docker run -p 8181:8181 --link db:db -e DATABASE_URL="postgresql://root@localhost:26257?sslcert=certs%5Cclient.root.crt&sslkey=certs%5Cclient.root.key&sslmode=verify-full&sslrootcert=certs%5Cca.crt" sosedoff/pgweb --network=host
C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: Cannot link to a non running container: /reverent_wiles AS /peaceful_hawking/db.

The docker daemon is running as verified with docker info

sosedoff commented 6 years ago

The way you start container does not look right. The error says that the container you're trying to link is not running. Also, when you're starting container with host network you dont need to specify ports because they map to the host automatically. Finally, when you're using certs with pgweb you have to make sure they're in container, or at least they're mounted via a volume.

Alternatively, you can run pgweb without host network, but you will need to change the DATABASE_URL from postgresql://root@localhost to postgres://root@db. I'd try that first

sosedoff commented 6 years ago

@natiki Im closing this issue for now. Seems like a docker problem. I just tested the pull with a fresh DO server and was able to pull the image without any login. Also, here's the issue for reference: https://github.com/docker/hub-feedback/issues/1098.

cbandy commented 6 years ago

I think --network=host needs to come before the image name.

natiki commented 6 years ago
docker run -p 8181:8181 --link db:db -e DATABASE_URL="postgresql://root@localhost:26257?sslcert=certs%5Cclient.root.crt&sslkey=certs%5Cclient.root.key&sslmode=verify-full&sslrootcert=certs%5Cca.crt" --network=host sosedoff/pgweb
docker: Error response from daemon: conflicting options: host type networking can't be used with links. This would result in undefined behavior.
See 'docker run --help'.

and then:

docker run -p 8181:8181 -e DATABASE_URL="postgresql://root@localhost:26257?sslcert=certs%5Cclient.root.crt&sslkey=certs%5Cclient.root.key&sslmode=verify-full&sslrootcert=certs%5Cca.crt" --network=host sosedoff/pgweb
WARNING: Published ports are discarded when using host network mode
Pgweb v0.9.12 (git: 9af721176bf7b41366f0de8251fff0b47da8fce3)
Connecting to server...
Error: dial tcp [::1]:26257: connect: connection refused
sosedoff commented 6 years ago

Here's the baseline script for you to get started with pgweb and cockroach db using docker containers:

docker run -d --name=cockroach-server -p 26257:26257 -p 8080:8080 cockroachdb/cockroach:v2.0.5 start --insecure

docker exec -it cockroach-server ./cockroach sql --insecure -e 'CREATE DATABASE test'

docker run -p 8081:8081 --link=cockroach-server -d -e DATABASE_URL=postgres://root@cockroach-server:26257/test?sslmode=disable sosedoff/pgweb

Also, host networking might not work on mac (or win) the same way it works on linux so i cant really say if whatever you're doing is going to succeed. But the example i provided works and should be the same across all stacks.