From: Elton Pinto Date: Thu, 9 Jan 2025 17:43:23 +0000 (-0500) Subject: make image point to cs3210 org X-Git-Url: https://git.devinivas.org/?a=commitdiff_plain;h=dc16153fed1f123c42a0290933dd5695d26d927f;p=cs3210-lab0.git make image point to cs3210 org --- diff --git a/scripts/docker.sh b/scripts/docker.sh index 0bfd867..4b8b20e 100755 --- a/scripts/docker.sh +++ b/scripts/docker.sh @@ -5,9 +5,9 @@ function usage() { Usage: $0 [--attach] [--pull] Options: - (default): create Docker image "xv6" and attach + (default): create Docker image "xv6" and attach --attach: attach to created Docker image (useful for GDB) - --pull: load latest Docker image from registry + --pull: load latest Docker image from registry USAGE exit 1 } @@ -18,33 +18,46 @@ ROOT_DIR="$(pwd)" PULL=false ATTACH=false +IMAGE="cs3210/xv6:latest" for arg in "$@"; do case $arg in --pull) PULL=true - shift + shift ;; --attach) ATTACH=true - shift + shift ;; -h | --help) - usage # run usage function on help + usage ;; *) - usage # run usage function if wrong argument provided + usage ;; esac done +# Function to check if Docker image exists locally +function image_exists() { + docker image inspect "$IMAGE" > /dev/null 2>&1 +} + +# Auto-pull image if it doesn't exist +if ! image_exists; then + echo "Image $IMAGE not found locally. Pulling from DockerHub..." + docker pull "$IMAGE" +fi + +# Handle options if [[ $PULL == true ]]; then echo "Pulling latest image from DockerHub" - docker pull jackwolfard/cs3210:latest + docker pull "$IMAGE" elif [[ $ATTACH == true ]]; then echo "Attaching to container" - docker exec -it xv6 bash + docker exec -it xv6 bash else echo "Starting xv6 container" - docker run --rm -it --name="xv6" -v "${ROOT_DIR}/":/xv6 -w="/xv6" jackwolfard/cs3210:latest + docker run --rm -it --name="xv6" -v "${ROOT_DIR}/":/xv6:z -w="/xv6" "$IMAGE" fi diff --git a/scripts/windows/docker/pull.bat b/scripts/windows/docker/pull.bat index 22551f4..5989dc3 100644 --- a/scripts/windows/docker/pull.bat +++ b/scripts/windows/docker/pull.bat @@ -1 +1 @@ -docker pull jackwolfard/cs3210:latest +docker pull cs3210/xv6:latest diff --git a/scripts/windows/docker/run.bat b/scripts/windows/docker/run.bat index a12f549..619553f 100644 --- a/scripts/windows/docker/run.bat +++ b/scripts/windows/docker/run.bat @@ -3,4 +3,4 @@ setlocal SET parent=%~dp0 FOR %%a IN ("%parent%\..\..\..") DO SET "root=%%~fa" @ECHO ON -docker run --rm -it --name="xv6" -v %root%:/xv6 -w="/xv6" jackwolfard/cs3210:latest +docker run --rm -it --name="xv6" -v %root%:/xv6 -w="/xv6" cs3210/xv6:latest