To make a call to a Spring Boot REST endpoint from an ArangoDB Foxx service within a Docker network, you can use the following steps:
Provide a name to both the Spring Boot app and the ArangoDB container:
docker run --name spring-boot-app -p 8080:8080 myimage
docker run --name arangodb -p 8529:8529 myimage
Create a Docker network:
docker network create mynetwork
Attach both containers to the network:
docker network connect mynetwork spring-boot-app
docker network connect mynetwork arangodb
Modify the Foxx service code to use the DNS name of the Spring Boot container to send a HTTP request:
const url = 'http://spring-boot-app:8080/api/endpoint';
const response = request.post(url, { body: { data } });
spring-boot-app
refers to the name given to the Spring Boot container in step 1.8080
is the port that the Spring Boot app is exposed on./api/endpoint
is the path of the REST endpoint on the Spring Boot app.Use the docker-compose
tool to automate the process:
version: "3.9"
services:
spring-boot:
build: ./spring-boot
ports:
- "8080:8080"
networks:
- mynetwork
arangodb:
build: ./arangodb
ports:
- "8529:8529"
networks:
- mynetwork
networks:
mynetwork:
driver: bridge
networks
parameter to specify the network to connect the container to.mynetwork
is the name of the network created in step 2.By following the above steps, you can make a call to a Spring Boot REST endpoint from an ArangoDB Foxx service within a Docker network.
Asked: 2022-09-15 11:00:00 +0000
Seen: 11 times
Last updated: Jun 29 '22