Hi Team,
I am trying to access my spring boot application using docker container and that I am trying to do using Circle CI 2.0. I have read some discussions on this forum that there are some issues using setup_remote_docker and even I have also tried it is not working and I am not able curl to the localhost.
Now that I am using machine executor, I am able to curl to the localhost and get a response, but that is only if I am doing ssh to the machine. However, this is not working from the config.yml file. curl is not giving me correct response, even though the container is up and running.
Please see below my config.yml and the corresponding error -
version: 2
jobs:
build:
machine: true
working_directory: ~/rbsmicroservices/services/productservice
environment:
TEST_REPORTS: /tmp/test-reports
HOST_PORT: 8190
CONTAINER_PORT: 8190
SERVICE_NAME: productservice
steps:
- checkout:
path: ~/rbsmicroservices
- run: mvn clean install
- run: |
docker image build -t microservices/${SERVICE_NAME} .
docker run -d -p ${HOST_PORT}:${CONTAINER_PORT} --name ${SERVICE_NAME} microservices/${SERVICE_NAME}
docker ps -all
sleep 10
curl --retry 10 --retry-delay 5 -v http://localhost:8190/productIds?id=2
curl -s -o /dev/null -I -w "%{http_code}" http://localhost:8190/productIds?id=2
Error -
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6e4f38c792e0 microservices/productservice "/usr/bin/java -ja..." Less than a second ago Up Less than a second 0.0.0.0:8190->8190/tcp productservice
*** Hostname was NOT found in DNS cache**
*** Trying 127.0.0.1...**
*** Connected to localhost (127.0.0.1) port 8190 (#0)**
**> GET /productIds?id=2 HTTP/1.1**
**> User-Agent: curl/7.35.0**
**> Host: localhost:8190**
**> Accept: */***
**> **
*** Recv failure: Connection reset by peer**
*** Closing connection 0**
**curl: (56) Recv failure: Connection reset by peer**
**Exited with code 56**
However, when I am ssh to the machine, I am able to curl on the localhost and getting a 200 response.
Could you please help me here, what details are wrong in my config.yml file and why I am unable to curl to the local host.
Thanks, Sujit