The docker-compose documentation specifies that links is deprecated and should be replaced with depends_on. Using Depends On to Build Communication Between Services additionally, password and DB has changed accordingly.īetter Solution: Use a separate application.properties file for docker-compose based deployments and set that via profiles. Here as you can see we are using that link value we used in docker-compose definition for host/IP address. Then it will connect with the database running with this docker-compose.Įnvironment – In this section, we are setting the MySQL database name, MySQL username and password for the application and root password.Īll done, Now let’s change our application.properties to support this database and application server setup. So we can use database when defining IP address for the database connection on our spring boot application. Links – Here we are setting a link with app_db service. Ports – Here we are mapping local machine port along with port inside a docker container. Restart – always Always restart the container if it stops. If it is manually stopped, it is restarted only when Docker daemon restarts or the container itself is manually restarted. More to research: We can do the same to spring boot API docker image as well, Just push that image to docker-hub and you can directly use given image name and version for this setup as well. It will download from docker registry and start when needed. mysql_db – MySQL DB which runs on port 3306Įxplanation about the configurations I have used in this docker-compose file,īuild – Here we should introduce the image name to build under that service, Here we have our Dockerfile which was developed for the API in the same level with docker-compose.yml so using “.” it will capture that docker file and build the handle the api_service when executing this file.Īdditionally, we have introduced mysql:8.0 as the docker image for MySQL DB.api_service – Spring Boot REST API which runs on port 8080.So add the following content into the docker-compose.yml file, version: "3.7" I’ll start with using links to build communication between both.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |