-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add sanity test for docker build and run
- Loading branch information
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
|
||
# # Define image name | ||
IMAGE_NAME="myimage:latest" | ||
|
||
# Step 1: Build the Docker image | ||
docker build -f Dockerfile.intel -t $IMAGE_NAME . | ||
|
||
# Check if the build was successful | ||
if [ $? -ne 0 ]; then | ||
echo "Docker image build failed." | ||
exit 1 | ||
fi | ||
|
||
# Step 2: Run a container from the built image in detached mode with an override command | ||
CONTAINER_ID=$(docker run -d $IMAGE_NAME tail -f /dev/null) | ||
|
||
# Step 3: Check if the container is running | ||
if docker inspect -f '{{.State.Running}}' $CONTAINER_ID 2>/dev/null | grep -q 'true'; then | ||
echo "Container is running." | ||
else | ||
echo "Container failed to start." | ||
docker logs $CONTAINER_ID 2>/dev/null || echo "No container ID found." | ||
exit 1 | ||
fi | ||
|
||
# Step 4: Clean up - stop and remove the container | ||
docker stop $CONTAINER_ID | ||
docker rm $CONTAINER_ID | ||
|
||
echo "Sanity test completed successfully." |