Docker.io - Docker connection between application and database containers

I am trying to use my Scala-Akka application with my MySQL database on two separate Docker containers. I found out that Docker allows developers to associate their application with their databases with a flag named --link. In my Dockerfiles, in which I used to create my images, I add 8080 to it in EXPOSE 3306.

And this is how I run the containers:

docker run -d -p 3306:3306 --name mysql centos6mysql
docker run -d -p 8080:8080 --name scalaapp --link mysql:db centos6scala

After starting the containers, I used docker ps and I can see the active containers. However, it looks like the application container is not using the database from the MySQL container. Does anyone know what happened?

+4
source share
1 answer

Docker . Docker URL, IP, . . :

DB_NAME=/web2/db
DB_PORT=tcp://172.17.0.5:5432
DB_PORT_5432_TCP=tcp://172.17.0.5:5432
DB_PORT_5432_TCP_PROTO=tcp
DB_PORT_5432_TCP_PORT=5432
DB_PORT_5432_TCP_ADDR=172.17.0.5

Akka DB. . Docker .

, - script, - :

./restcore --Ddb.default.db="jdbc:mysql//${DB_PORT_3306_TCP_ADDR}:${DB_PORT_3306_TCP_PORT"
+6

All Articles