Skip to content

Commit

Permalink
misc change
Browse files Browse the repository at this point in the history
  • Loading branch information
gauravsaini04 committed Dec 13, 2024
1 parent 6c12229 commit c081194
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
14 changes: 7 additions & 7 deletions test/common-utils/allow_shell_history.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ CMD ["bash"]
EOL
# Build and tag the image
docker build -t $IMAGE_NAME .
sudo docker build -t $IMAGE_NAME .
# Run the container again for attaching volume
CONTAINER_ID=$(docker run -v devcontainers:/devcontainers -itd $IMAGE_NAME) > /dev/null
CONTAINER_ID=$(sudo docker run -v devcontainers:/devcontainers -itd $IMAGE_NAME) > /dev/null
# Output the container ID to a file
echo "CONTAINER_ID=$CONTAINER_ID" > /tmp/container_id.txt
Expand All @@ -99,25 +99,25 @@ add_shell_history() {
local container_id=$1
local history_message=$2
echo -e "\nWriting shell history: $history_message";
docker exec -it $container_id /bin/bash -c "echo \"$history_message\" >> ~/.bash_history"
sudo docker exec -it $container_id /bin/bash -c "echo \"$history_message\" >> ~/.bash_history"
}

# Function to check shell history
check_shell_history() {
local container_id=$1
echo -e "\nChecking shell history from container: ";
docker exec -it $container_id /bin/bash -c "cat ~/.bash_history"
sudo docker exec -it $container_id /bin/bash -c "cat ~/.bash_history"
}

source /tmp/container_id.txt

# Start the container and add shell history
docker start $CONTAINER_ID > /dev/null
sudo docker start $CONTAINER_ID > /dev/null
add_shell_history $CONTAINER_ID "Shell History for First Container Created."
docker stop $CONTAINER_ID > /dev/null
sudo docker stop $CONTAINER_ID > /dev/null

# Start the container and check shell history persistence
docker start $CONTAINER_ID > /dev/null
sudo docker start $CONTAINER_ID > /dev/null
check_shell_history $CONTAINER_ID

# Report result
Expand Down
32 changes: 16 additions & 16 deletions test/common-utils/scenarios.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
{
"allow_shell_history": {
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"docker-in-docker": {},
"common-utils": {
"installZsh": true,
"allowShellHistory": true
}
},
"overrideFeatureInstallOrder": [
"./common-utils",
"./docker-in-docker"
],
"remoteUser": "vscode",
"containerUser": "vscode"
},
"bionic": {
"image": "ubuntu:bionic",
"remoteUser": "devcontainer",
Expand Down Expand Up @@ -292,21 +308,5 @@
"features": {
"common-utils": {}
}
},
"allow_shell_history": {
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"docker-in-docker": {},
"common-utils": {
"installZsh": true,
"allowShellHistory": true
}
},
"overrideFeatureInstallOrder": [
"./common-utils",
"./docker-in-docker"
],
"remoteUser": "vscode",
"containerUser": "vscode"
}
}

0 comments on commit c081194

Please sign in to comment.