Link between two docker containers in a network
I have a docker network between geoserver and postgres. When I do docker inspect
container name I can see the two are linked. When I exec into the geoserver container I can ping the postgres container but when I try to connect to a postgres db from within the geoserver container I get an error
psql: could not translate host name
postgresto address: Name or service not known
Running docker-compose with mysql and own docker container Unable to access my web2py app login page by running docker container using gae Docker : Install Maven dependencies during build stage only? Host Global Python Object in Docker Container Docker-Compose - Server exposes several ports but only one of the ports is not accessible in the client Multiple docker images run from docker file
Here is an example of my docker-compose:
version: '2' services: postgres: image: kartoza/postgis:9.5-2.2 geoserver: image: geonode/geoserver hostname: geonode-geoserver links: - postgres:postgres ports: - "8181:8080"
I know with docker networks the
/etc/hosts file is not populated. How can I enable accessing the database from geoserver container.
3 Solutions collect form web for “Link between two docker containers in a network”
geoserver service is probably starting before the
postgres service is available.
You should use a defined network for resolve names without links and use depends_on for postgres start before geoserver.
in the geoserver service definition change:
You need to match the service name to the image name