Tomee and Postgres communication with Docker
I have 2 Dockerfiles, one for tomee and another one for Postgres:
- How to put sidekiq into Docker in a rails application?
- Why is this docker image allowed past the firewall?
- Best practices for Publishing an ASP.NET 5 app to Docker on Linux with Visual Studio
- Making a karaf/docker service read a configuration file
- Different env-file but same yml with Docker Compose?
- How to start a Docker container with cloud-config file for CoreOS?
After the creation of the image (postgres-img and tomee-img), I run the containers in this way:
docker run -p 5432:5432 -e POSTGRES_PASSWORD=postgres --name= postgress postgres-image
and then tomee
docker crete -p 8080:8080 --link postgress:postgress --name=tomcatt tomee-img
When I start the containers all work, I can see the web application from browser at 192.168.99.100:8080 and I can see the remote db on PGAdmin by using the ip 192.168.99.100:5432.
As you can see, I link tomee to postgress with –link so in tomee.xml I set
because I saw that after the linking you can use the alias you choose.
I saw this solution in this thread: Docker Tomcat container unable to access Postgres container
The problem is that the web application does not communicate with the db that remains always empty. It’s like the tomee.xml is useless.
Is there another way to connect the containers?