File size: 2,093 Bytes
26f256d 6d62d09 26f256d 6d62d09 26f256d 6d62d09 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
@echo off
:: Define variables
set IMAGE_NAME=SaprotHubImage.tar
set CONTAINER_NAME=SaprotHubLocal
set PORT=12315
set DIRECTORY_PATH=/root/SaprotHub/local_server
set IMAGE_TAG=saprothub_image
:: Check if Docker is installed
where docker >nul 2>nul
if %errorlevel% neq 0 (
echo Docker is not installed. Please install Docker Desktop first.
pause
exit /b
)
:waitForDocker
echo Checking if Docker is ready...
docker info >nul 2>nul
if %errorlevel% neq 0 (
echo Docker is not running. Please start Docker Desktop.
pause
exit /b
)
:: Check if Docker image exists
echo Checking if Docker image exists...
docker images | findstr %IMAGE_TAG% >nul
if errorlevel 1 (
echo The image does not exist, importing the image...
docker load -i %IMAGE_NAME%
if errorlevel 1 (
echo Failed to import Docker image.
pause
exit /b
)
) else (
echo The image already exists.
)
:: Check if Docker container exists
echo Checking if Docker container exists...
docker ps -a | findstr %CONTAINER_NAME% >nul
if errorlevel 1 (
echo The container does not exist, creating and starting the container...
docker run -d --name %CONTAINER_NAME% -p %PORT%:12315 %IMAGE_TAG% /bin/bash -c "while true; do sleep 1000; done"
if errorlevel 1 (
echo Failed to create and start Docker container.
pause
exit /b
)
) else (
echo The container already exists, starting the container...
docker start %CONTAINER_NAME%
if errorlevel 1 (
echo Failed to start Docker container.
pause
exit /b
)
)
:: Enter the Docker container and start a bash shell
echo Entering the Docker container and starting bash shell...
docker exec -it %CONTAINER_NAME% /bin/bash
if errorlevel 1 (
echo Failed to start bash shell inside the Docker container.
pause
exit /b
)
echo Now inside the Docker container. Run the following commands manually:
echo chmod +x %DIRECTORY_PATH%/run.sh
echo cd %DIRECTORY_PATH%
echo ./run.sh
pause
|