Hi,
From what I can gather, you are trying to run 2 MATLAB docker images simultaneously using docker-compose and call 1 image from another.
Here's a guide on how MATLAB Docker images can interact when deployed with Docker Compose:
- In this example, two functions have been created: thisAdds and makeCalls:
function c = thisadds(a, b)
c = a + b;
end
When specifying the connection, instead of using "localhost," the local IP address is used. This IP can be found using various methods, such as executing ifconfig (requires net-tools) on the WSL.
- These functions can be compiled using the “compiler.build.productionServerArchive” command.
(For thisadds.m)
thisAddsObj = compiler.build.productionServerArchive('thisadds.m',...
'FunctionSignatures','thisaddsFunctionSignatures.json',...
'ArchiveName','thisaddsarchive','Verbose','on')
(For makecall.m)
makecallObj = compiler.build.productionServerArchive('makecall.m',...
'FunctionSignatures','makecallFunctionSignatures.json',...
'ArchiveName','makecallarchive','Verbose','on')
Additionally, a function signature has been created for makeCalls. More information about function signatures can be found at the following link:
- The Docker images are created using the “compiler.package.microserviceDockerImage” function.
(To create thisadds docker image)
compiler.package.microserviceDockerImage(thisAddsObj,'ImageName','thisadds')
(To create makecall docker image)
compiler.package.microserviceDockerImage(makecallObj,'ImageName','makecall')
- Next, access the WSL to verify the creation of Docker images. The names of the images should be listed:
docker images
- Create a docker-compose.yml file to configure the setup.
Note: To change the endpoint from 9910, modifications in the MATLAB image are necessary; simply changing the port mapping from 5000:5000 will not suffice without adjustments.
- Run Docker Compose to start the services:
docker-compose up
- Finally, call the makeCalls Docker image to test the setup:
Voila, it works!!