Docker Community Forums

Share and learn in the Docker community.

Docker run on container but not run server

i create Jenkinsfile, Dockerfile, Dockerfile.test to CI and CD my server API on GitHub, i build it on Jenkins and the build was successfully, and my docker run on the container as well,
on Jenkinsfile stages, i create for test and deploy on server API,
and using docker for the container

i also run Jenkins on docker also,
using docker-compose

here is my Dockerfile on my ubuntu server

FROM jenkins/jenkins:lts

USER root

and here is my docker-compose on ubuntu server

version: '3'

services:

  jenkins:
    build: .
    container_name: jenkins
    privileged: true
    restart: always
    ports:
      - 8080:8080
    volumes:
      - ./jenkins_home:/var/jenkins_home
      - /var/run/docker.sock:/var/run/docker.sock
      - /usr/bin/docker:/usr/bin/docker

  registry:
    image: registry
    container_name: registry
    restart: always
    ports:
      - 5000:5000

what i did above , i follow [this intruction][1]
then i tried ro run it and login on my jenkins server,

my jenkinsfile something like this

  try {
    stage('Checkout') {
      checkout scm
    }
    stage('Environment') {
      sh 'git --version'
      echo "Branch: ${env.BRANCH_NAME}"
      sh 'docker -v'
      sh 'printenv'
    }
    stage('Build Docker test'){
     sh 'docker build -t employee-test -f Dockerfile.test --no-cache .'
    }
    stage('Docker test'){
      sh 'docker run --rm employee-test'
    }
    stage('Clean Docker test'){
      sh 'docker rmi employee-test'
    }
    stage('Deploy'){
      if(env.BRANCH_NAME == 'master'){
        sh 'docker build -t employee --no-cache .'
        sh 'docker run -d -p 4000:4000 -e DB_USERNAME=admin -e DB_PASSWORD=adminxxx -e DB_NAME=employee employee'
      }
    }
  }
  catch (err) {
    throw err
  }
}

and my Dockerfile for those jobs

FROM node:carbon

RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get -y install autoconf automake libtool nasm make pkg-config git apt-utils

RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

RUN npm -v
RUN node -v

COPY ./server/ /usr/src/app

RUN npm install

EXPOSE 4000

ENV PORT 4000
ENV DB_USERNAME admin
ENV DB_PASSWORD adminxxx
ENV DB_NAME employee

CMD [ "npm", "run", "dev" ]

the jenkins job build it successfully and on the last stage my Jenkins, u can see that i run it on my docker container on my ubuntu server, after that finish, i tried to call server API on postman for http://ip-server:4000 , but it was nothing response, and i did set up the firewall tcp on my ubuntu serrver though

this article i follow

how can i solve this? so after Jenkins job finish, what i want i could call that server API on my postman to test it
i have build 14 times on jenkins for 2 days and find out but still cant work till now on my server