-
Notifications
You must be signed in to change notification settings - Fork 11
Fix the issue where run.sh deletes the container upon exit after creating it from an image each time. #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -101,7 +101,27 @@ echo "[*] XAUTHORITY=$XAUTHORITY" | |||||||||||||||||||||||||
| echo "[*] XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR" | ||||||||||||||||||||||||||
| xhost +local:docker 2>/dev/null || xhost + 2>/dev/null || echo "[*] Warning: Could not set xhost permissions" | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| docker run -it --rm \ | ||||||||||||||||||||||||||
| # Check if container already exists | ||||||||||||||||||||||||||
| if docker ps -a --format '{{.Names}}' | grep -q "^${CONTAINER_NAME}$"; then | ||||||||||||||||||||||||||
| echo "[*] Container ${CONTAINER_NAME} already exists" | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # Check if container is running | ||||||||||||||||||||||||||
| if docker ps --format '{{.Names}}' | grep -q "^${CONTAINER_NAME}$"; then | ||||||||||||||||||||||||||
| echo "[*] Container is already running, attaching..." | ||||||||||||||||||||||||||
| docker exec -it $CONTAINER_NAME bash /docker-entrypoint.sh | ||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||
| echo "[*] Container exists but is stopped, starting and attaching..." | ||||||||||||||||||||||||||
| docker start $CONTAINER_NAME | ||||||||||||||||||||||||||
| sleep 2 | ||||||||||||||||||||||||||
| docker exec -it $CONTAINER_NAME bash /docker-entrypoint.sh | ||||||||||||||||||||||||||
|
Comment on lines
+114
to
+116
|
||||||||||||||||||||||||||
| docker start $CONTAINER_NAME | |
| sleep 2 | |
| docker exec -it $CONTAINER_NAME bash /docker-entrypoint.sh | |
| docker start "$CONTAINER_NAME" | |
| echo "[*] Waiting for container to be running..." | |
| for i in {1..10}; do | |
| if docker inspect -f '{{.State.Running}}' "$CONTAINER_NAME" 2>/dev/null | grep -q "true"; then | |
| break | |
| fi | |
| sleep 1 | |
| done | |
| docker exec -it "$CONTAINER_NAME" bash /docker-entrypoint.sh |
Copilot
AI
Jan 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When reusing an existing container with docker exec, the script bypasses the volume mounts, environment variables, GPU arguments, and network settings that are only applied during container creation. This means if any of these configurations change (e.g., GPU_ARGS, NETWORK_ARGS, or volume paths), the existing container will continue using outdated settings. Consider adding a comment warning users that they need to use the -d flag to delete and recreate the container if they modify any docker run arguments, or implement a mechanism to detect configuration changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running the docker-entrypoint.sh script multiple times via docker exec when attaching to an existing container will cause unintended side effects. The entrypoint script performs actions like apt install, modifying .bashrc, and setting up directories. Running it repeatedly will append duplicate 'source /opt/ros/humble/setup.bash' lines to .bashrc and re-run apt install on every attachment. Consider either: 1) using 'docker exec -it CONTAINER_NAME bash' without running the entrypoint for re-attachments, or 2) making the entrypoint script idempotent with guards to prevent duplicate operations.