Docker service exits on deploy-over-SSH from Jenkins but manually succeeds

  docker, dockerfile, jenkins, ssh

I have a strange issue. I have configured a SSH_USER on Jenkins and trying to deploy a simple docker-service with "deploy-over-SSH".
Every time I deploy it Exits as below, and logs just says "Terminated"

$ docker ps -a
CONTAINER ID  IMAGE                                       COMMAND               CREATED         STATUS                       PORTS                   NAMES
bea48e1ee755  localhost/my-image:latest  /bin/sh -c npm ru...  13 seconds ago  Exited (143) 13 seconds ago  0.0.0.0:6007->3000/tcp  my-cont
$ docker logs my-cont
Terminated

But if I try running manually on the same server with same SSH_USER, I am able to run docker container successfully.

docker run -d -it -p 6007:3000 --name my-cont my-image

$ docker ps -a
CONTAINER ID  IMAGE                                       COMMAND               CREATED         STATUS                       PORTS                   NAMES
nce48e1ee721  localhost/my-image:latest  /bin/sh -c npm ru...  21 minutes ago  21 minutes ago  0.0.0.0:6007->3000/tcp  my-cont

The script I am running over-SSH is very simple from Jenkins, I am passing the Port from Jenkins,

$ bash ./run.sh $Port
docker run -d -it -p $1:3000 --name my-cont my-image

Not sure , what is causing the issue.

Source: Docker Questions

LEAVE A COMMENT