title: How to remove docker container using port number
body: <ul>
  <li>I have Node services which are running in Docker container
  
  <ul>
  <li>I am using shell script to run these services</li>
  <li>I want to run three different instances of the same service on 3 different port. say <code>9011 9022 9033</code></li>
  <li>I also want it to configure it in such a way that after every new deployment it should stop the previous service and remove it</li>
  <li>I am using <code>docker rm test-service</code> to remove it but it will remove other instances too.</li>
  <li>by this approach only once instance can be running.</li>
  </ul></li>
  </ul>
  
  <p><strong>Is there any way to remove Docker service running on the specific port</strong>.</p>
  
  <p>here is my shell script</p>
  
  <pre><code>#!/bin/bash
  ORGANISATION="$1"
  SERVICE_NAME="$2"
  VERSION="$3"
  ENVIRONMENT="$4"
  INTERNAL_PORT_NUMBER="$5"
  EXTERNAL_PORT_NUMBER="$6"
  NETWORK="$7"
  docker build -t ${ORGANISATION}/${SERVICE_NAME}:${VERSION} --build-arg PORT=${INTERNAL_PORT_NUMBER} --build-arg ENVIRONMENT=${ENVIRONMENT} --no-cache .
  docker stop ${SERVICE_NAME}
  docker rm ${SERVICE_NAME}
  
  sudo npm install
  sudo npm install -g express
  docker run -p ${EXTERNAL_PORT_NUMBER}:${INTERNAL_PORT_NUMBER} --network ${NETWORK} --name ${SERVICE_NAME} --restart always -itd ${ORGANISATION}/${SERVICE_NAME}:${VERSION}
  </code></pre>