Move project to Docker Compose #3
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This reconfigures the project to use Docker Compose, primarily to simplify configuration and make service discovery less manual. Compose makes this particularly simple as it lets us specify apps in
docker-compose.yaml
that can talk to each other via a network created by default. See the link for more details about how this works.We can talk to our containers over the ports specified in
docker-compose.yaml
, which follow the format "host-port:container-port". Docker handles all the networking around forwarding traffic from the host port to the container port.This cannot be merged as-is, because I think there is an issue around Spring not liking custom hostnames. I suspect there may be an additional method that needs to be called to set a custom hostname on the request in
app/.../Controller.java
, but did not play with this much myself as I don't have a Java development environment set up, and for some reason requests do not seem to be showing up in the Spring logs that we see when runningdocker-compose up
ordocker-compose logs app
.The specific error I get when doing a
PUT
tohttp://0.0.0.0:7001/takeFromInventory?name=Chamber&quantity=1
isjava.net.ConnectException: Connection refused (Connection refused)
. The issue does not seem to be with the Docker networking configuration because we're making it to the Java app, and because I can make requests to theinventory
app by itself without any issues.