Search⌘ K
AI Features

Connecting the DB Container

Explore how to connect an application container to a MySQL database container using Docker's bridge network and linking feature. Understand network inspection, container linking, and running database initialization scripts with Docker for seamless app-database communication.

In this lesson, we will complete the remaining steps.

For this lesson, git checkout 6589c4f6586ca7efb25d8819fc886181dec771e9 to get to the specific code.

Till now, we have gotten to get the MySQL shell of the container and checked for our database. The next step is to establish a connection between the app and the database container.

App and DB connectivity

As per the diagram below, by default, both containers should be in the same bridge network. So, let’s check for that.

Type ...