From 84bbc4e23b111a6a9b9a360af1767bba1037cacc Mon Sep 17 00:00:00 2001
From: C24053098 <akbarb@cardiff.ac.uk>
Date: Wed, 9 Apr 2025 22:22:59 +0100
Subject: [PATCH] Switch to host networking to avoid Docker bridge crash

---
 Docker/Dockerfile => Dockerfile |  0
 docker-compose.yml              | 22 +++++++---------------
 2 files changed, 7 insertions(+), 15 deletions(-)
 rename Docker/Dockerfile => Dockerfile (100%)

diff --git a/Docker/Dockerfile b/Dockerfile
similarity index 100%
rename from Docker/Dockerfile
rename to Dockerfile
diff --git a/docker-compose.yml b/docker-compose.yml
index fbc75d9..149d096 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -4,8 +4,8 @@ services:
   mariadb:
     image: mariadb:10.11.11
     container_name: mariadb
-    ports:
-      - "3306:3306"
+    # Host networking means this container listens on the host’s 3306
+    network_mode: "host"
     environment:
       MYSQL_ROOT_PASSWORD: comsc
       MYSQL_DATABASE: healthcare
@@ -16,31 +16,23 @@ services:
         limits:
           cpus: '1'
           memory: 1024M
-    networks:
-      - healthcare_network
-      
+
   healthcare_01:
     build:
       context: .
       dockerfile: Docker/Dockerfile
     container_name: healthcare_01
+    # Shares the host network, so no port mapping is needed
+    network_mode: "host"
     environment:
-      - DB_URL=jdbc:mariadb://mariadb:3306/healthcare?createDatabaseIfNotExist=true
-      - SPRING_DATASOURCE_URL=jdbc:mariadb://mariadb:3306/healthcare?createDatabaseIfNotExist=true
+      - DB_URL=jdbc:mariadb://localhost:3306/healthcare?createDatabaseIfNotExist=true
+      - SPRING_DATASOURCE_URL=jdbc:mariadb://localhost:3306/healthcare?createDatabaseIfNotExist=true
       - SPRING_DATASOURCE_USERNAME=root
       - SPRING_DATASOURCE_PASSWORD=comsc
-    ports:
-      - "8080:8080"
     deploy:
       resources:
         limits:
           cpus: '1'
           memory: 1536M
-    networks:
-      - healthcare_network
     depends_on:
       - mariadb
-
-networks:
-  healthcare_network:
-    name: healthcare_net
\ No newline at end of file
-- 
GitLab