#!/bin/bash
# ./docker_restart.sh keyfunc.tencentcloudcr.com/test/mdx bcdf170 /EPM2/POSTGRE
DOCKER_IMAGE_NAME=$1
DOCKER_IMAGE_VERSION=$2
MDX_DATA=$3

dockerid=`docker ps -a | tail -n+2 | grep mdx_only | awk '{print $1}'`
echo "docker to rm $dockerid"
if [ $dockerid ];then 
   docker stop $dockerid
   docker rm $dockerid
   #ensure we use latest image
   #docker rmi ${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_VERSION}
   #echo "docker del done"
fi
echo "start docker"
#docker run -d --name mdx_only1 --restart=always --ulimit stack=102400:102400 -v /data_disk/pg_data/mdx/config.json:/home/mdx/config.json -p 9010:9019 keyfunc.tencentcloudcr.com/test/mdx:667b1ed
docker run -d --name mdx_only --restart=always --ulimit stack=-1 -v ${MDX_DATA}:/tmp -v ${MDX_DATA}/config.json:/home/mdx/config.json -p 9010:9019 ${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_VERSION}
