Compose pulls all the required Docker image, builds an image for your code, and starts the services you defined. Once you have completed the above configurations,next step is to start the application.In the current project directory, run docker-compose up. Image – Add entries for host connections #4.Build and run your app with Compose Image – Modify nfĪlso edit pg_hba.conf file to add entry for the host connections like below host all all 0.0.0.0/0 md5 #3.Configure Postgresql to able to connect from Docker containersĪssuming Postgresql is already installed on the host machine, follow the below steps to configure the listen_addresses on nf to accept all connections. Also on your SpringBoot configuration (application.properties file) specify the external IP address of the database host like =jdbc:postgresql://:5432/postgres. If you have noticed, we haven’t created service for Postgresql application instead we would be using Postgresql database installed on the host.When you start the services, compose would start the dependent services as well. depends_on denotes the service dependencies.All the above services uses samplenet network.api : This is for spring boot application, it uses an image that’s built from the AppDockerfile in the current directory and forwards the exposed port 8080 on the container to port 8080 on the host machine.ui : This is for angular application,it uses an image that’s built from the UIDockerfile in the current directory and forwards the exposed port 4200 on the container to port 4200 on the host machine.RUN chmod -R 755 /usr/local/apache2/htdocs/ĮXPOSE 4200 Spring Boot API Docker file FROM openjdk:8-jreĪDD spring-boot-rest-postgresql-0.0.1-SNAPSHOT.jar spring-boot-rest-postgresql-0.0.1-SNAPSHOT.jarĮNTRYPOINT #2.Define services in Docker compose fileĬreate a file called docker-compose.yml in your project directory and paste the following: version: '3'Ībove compose file defines 2 services as below: htaccess /usr/local/apache2/htdocs/ĬOPY nf /usr/local/apache2/conf/nf Angular Application Docker file FROM httpd:2.4 Create a new project directory and copy all dockerfiles to this folder. We have already defined below docker files in the previous posts here & here. #3.Configure Postgresql to able to connect from Docker containers.#2.Define services in Docker compose file.In the next section, we can look at how to define services in compose file for sample application with Angular as front end, Spring Boot as API, and for database as Postgres but this will be located on the host. This quickstart assumes basic understanding of Docker concepts, please refer to earlier posts for understanding on Docker & how to install and containerize applications. Run docker-compose up and Compose starts and runs your entire app.Configure Postgresql to able to connect from Docker containers.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |