0% found this document useful (0 votes)
4 views1 page

Docker Networking Example

The document outlines the steps to set up a Docker network for microservices including a Eureka server, order service, product service, and a MySQL container. It provides commands for pulling and running the MySQL Docker container, creating a new user, and configuring the Dockerfile for Java applications. Additionally, it explains how to run the services using the host network to facilitate communication between containers through dynamic IP addresses managed by the Eureka server.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Docker Networking Example

The document outlines the steps to set up a Docker network for microservices including a Eureka server, order service, product service, and a MySQL container. It provides commands for pulling and running the MySQL Docker container, creating a new user, and configuring the Dockerfile for Java applications. Additionally, it explains how to run the services using the host network to facilitate communication between containers through dynamic IP addresses managed by the Eureka server.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

How to setup Docker Network between Microservices

1. Eureka server
2. Order service
3. Product service
4. MySQL docker container
Steps to run mysql docker container
sudo docker pull mysql/mysql-server:5.5
sudo docker run --name=mysql1 -e MYSQL_ROOT_HOST=% -p 3306:3306 -d
mysql/mysql-server:5.5
sudo docker logs mysql1 2>&1 | grep GENERATED
--this give generated root password
sudo docker exec -it mysql1 mysql -u root -p
password: give the generated password
this will take to sql shell
CREATE USER 'newUser'@'%' IDENTIFIED BY '<<generated password>>';
GRANT ALL PRIVILEGES ON *.* TO 'newUser'@'%' WITH GRANT OPTION;

Dockerfile
FROM openjdk:17-jdk-alpine
ARG JAR_FILE
COPY ${JAR_FILE} springbootapp.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-
jar","springbootapp.jar"]

sudo docker run -p 1111:1111 regservice

User network host so that these containers will use ip address or host name

sudo docker run --network host -p 9090:9090 productservice


sudo docker run --network host -p 8090:8090 orderservice

Attached is Eureka server dashboard which will display ip address of containers

When we try to access ordesrevice, this will get dynamically ip address of product
service from Eureka server and hit the product service url

You might also like