Thanks much for your reply. The container is running as shown by ‘docker compose ps’. Below is more console output:
docker compose up -d --no-color --wait
Container jenkins-docker-compose_master-echo-server-1 Recreate
Container jenkins-docker-compose_master-echo-server-1 Recreated
Container jenkins-docker-compose_master-echo-server-1 Starting
Container jenkins-docker-compose_master-echo-server-1 Started
[Pipeline] sh
docker compose ps
NAME COMMAND SERVICE STATUS PORTS
jenkins-docker-compose_master-echo-server-1 “node webserver” echo-server running 0.0.0.0:3000->80/tcp
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Run tests against the container)
[Pipeline] sh
My statement still stands, either your service isn’t running (finished starting up, or has quit) or not listening on that port. Maybe add a post { failure { sh('docker-compose logs') } } or something
Is your service listing on port 80? or port 3000? cause thats mapping port 3000 outside docker to port 80 inside docker.
Thanks again for your reply.
Yes, the docker container is running on Jenkins. The original service is on port 80 which is mapped to 3000.
I added post { always { sh('docker-compose logs') } }
Here is the output:
docker compose logs
jenkins-docker-compose_master-echo-server-1 | (node:1) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
jenkins-docker-compose_master-echo-server-1 | (Use node --trace-deprecation ... to show where the warning was created)
jenkins-docker-compose_master-echo-server-1 | Listening on port 80.
Thanks for the reply, but I am pretty sure that is not the problem. I tried many approaches, even manually starting containers and trying to access after making sure they are up and running, but still no luck. Only thing that is different is that I am running Jenkins inside docker container (dind). I guess it has to do something with docker networking but still cant find my way through
It’s not localhost:3000 (or whatever port you gave echo-server), but instead [port of your PC]:3000
e.g: instead of localhost:3000, put 172.25.16.1:3000
hope this helps!