Commit e0da09f3 authored by pasden's avatar pasden 💬
Browse files

Fix update_container_mirror.sh

parent a3e2c08b
#!/bin/sh
container_name="itinvent"
host_name="yourHost"
path_docker_containers="/volume1/docker"
container_data_path="${path_docker_containers}/${container_name}/"
docker stop $container_name
docker rm $container_name
docker pull mcr.microsoft.com/mssql/server:2019-latest
docker run --name $container_name \
--hostname $host_name \
-u 0:0 \
-v $container_data_path:/var/opt/mssql \
-e 'ACCEPT_EULA=Y' \
-e 'MSSQL_PID=Enterprise' \
-e 'MSSQL_ENABLE_HADR=1' \
-e 'MSSQL_AGENT_ENABLED=true' \
-e "MSSQL_MEMORY_LIMIT_MB=2048" \
-e 'TZ=Europe/Moscow' \
-p 1433:1433 \
-p 5022:5022 \
-d mcr.microsoft.com/mssql/server:2019-latest
docker logs -f $container_name
CONTAINER_NAME="itinvent"
IMAGE="mcr.microsoft.com/mssql/server:2019-latest"
APP_DIR=$(cd "$(dirname "$0")" && pwd)
PULL_RESULT=$(sudo docker pull $IMAGE | grep Status | awk -F':' '{print $2}' | awk '{print $1,$2,$3,$4,$5}')
echo "--"
if [ "$PULL_RESULT" = "Image is up to date" ]; then
echo "$PULL_RESULT"
exit 0
fi
echo "--"
sh -c "${APP_DIR}/backup_db.sh" && echo "backup container!"
echo "--"
sudo docker stop $CONTAINER_NAME && echo "stop container!"
echo "--"
sudo docker rm $CONTAINER_NAME && echo "remove container!"
echo "--"
sh -c "${APP_DIR}/start_container_mirror.sh" && echo "start container!"
echo "--"
sudo docker image rm "$(sudo docker images | grep "$(echo $IMAGE | awk -F':' '{print $1}')" | grep none | awk '{print $3}')" && echo "remove old image!"
#docker logs -f $CONTAINER_NAME
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment