Reputation: 14999
I've built Docker images for my Spring Boot (2.3) containers that I want to run on the same host. To do that, I planned on using different mapped ports on the host, ie
docker container run -d -p 8080:8080 myimages/image1
docker container run -d -p 8081:8080 myimages/image2
The container for image1 works fine (using Insomnia for a HTTP query against http://localhost:8080/mypath).
However, image2 isn't reachable: a POST results in 404 - Not Found
, a GET in Server returned nothing (no headers, no data)
(the last one is fine, the GET only returns what a previous POST provides). The container logs does show that the service is started ("Netty started on port(s): 8080 [...] Started [...] in 4.208 seconds") and the container runs.
If I only start image2 and map to 8080 on host, it works fine, so it's not the image. After some research, I also added
server.address=0.0.0.0
to application.yml, but it didn't help.
I also tried to start with
docker container run -d -p 8081:8081 -e "JAVA_OPTS=-Dserver.port=8081" myimages/image2
which results in the logs showing the service now runs on 8081, but the mapping still doesn't seem to work.
This is on Windows.
Why does this not work? At what point in the chain can this fail? It's a really simple service without authorization or anything.
Upvotes: 0
Views: 1217
Reputation: 14999
I found the problem; another program (I think my virus scanner) is already running on port 8081.
I'd delete the question if I thought that should have been obvious, but there really wasn't any indication anything was wrong with the port (no "already assigned" or suchlike), so if anyone stumbles upon this, maybe it will help.
Upvotes: 1