]> Devi Nivas Git - cs3210-lab1.git/commitdiff
make image point to cs3210 org
authorElton Pinto <eltonp3103@gmail.com>
Thu, 9 Jan 2025 17:45:06 +0000 (12:45 -0500)
committerElton Pinto <eltonp3103@gmail.com>
Thu, 9 Jan 2025 17:45:06 +0000 (12:45 -0500)
scripts/docker.sh
scripts/windows/docker/pull.bat
scripts/windows/docker/run.bat

index 1cf0f73c067da53631498cb5e3eedbb8665f0133..4b8b20e571d59e48d99ff85d5dd4af75f8d41373 100755 (executable)
@@ -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 cwebb45/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" cwebb45/cs3210:latest
+    docker run --rm -it --name="xv6" -v "${ROOT_DIR}/":/xv6:z -w="/xv6" "$IMAGE"
 fi
index 22551f4bb4f1760135ac677a82e042a70477edfc..5989dc3bef61ec3219883136b05089b0bfdc54d7 100644 (file)
@@ -1 +1 @@
-docker pull jackwolfard/cs3210:latest
+docker pull cs3210/xv6:latest
index a12f5498970d40241da2d8cb07a12804a5227b21..619553fe2f4c1e66a4fa82e95e3f2ce2aed7f8b9 100644 (file)
@@ -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