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
DOCKER - LAMP Stack issues - Premade Image Duplicate mappings when building docker package using sbt-native-packager Shortcut command for docker-compose build + down + up dockerized cassandra: java.lang.OutOfMemoryError: Java heap space Why use docker? Aren't java files like WAR files already running on JVM? CI: Should I run tests directly or through Docker container?
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