Openhands is an agentic LLM software development platform https://github.com/All-Hands-AI/OpenHands can run multiple instances of runtimes. Its a useful tool but extracting the workspace thru the browser is a bit of a painful experience and not always successful. Its more successful to use CLI.
When running openhands using the default docker method, it starts up a master session on port 3000 called openhands-app.
# docker ps
in 0.058s (0)
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e765ae1727f4 docker.all-hands.dev/all-hands-ai/runtime:0.24-nikolaik "/openhands/micromam…" 38 minutes ago Up 38 minutes 0.0.0.0:30792->30792/tcp, 0.0.0.0:41829->41829/tcp, 0.0.0.0:54946->54946/tcp, 0.0.0.0:55040->55040/tcp openhands-runtime-4d02bb19403c43f69d4a643adb9c6b97
c785d523b578 docker.all-hands.dev/all-hands-ai/runtime:0.24-nikolaik "/openhands/micromam…" 43 minutes ago Up 43 minutes 0.0.0.0:32330->32330/tcp, 0.0.0.0:46884->46884/tcp, 0.0.0.0:52091->52091/tcp, 0.0.0.0:55736->55736/tcp openhands-runtime-c2328803a36949b68681e5e5a37c7b06
d9bf26ff8aa9 docker.all-hands.dev/all-hands-ai/openhands:0.24 "/app/entrypoint.sh …" 44 minutes ago Up 44 minutes 0.0.0.0:3000->3000/tcp openhands-app
Then any future conversation or project (also known as runtime) that you have running, creates a new docker instance called openhands-runtime-ID.
The ID is the same as the conversation ID seen at the top of the URL bars. Each runtimes workspace is saved to that docker instances’s /workspace directory.
Use the following script to tar up the workspace to the root directory of the docker instance (so its not in the way of the workspace) and then extract it with docker copy using this bash script:
# one-liner - command to export out entire workspace from all running openhands runtimes into tar ball
docker ps | grep openhands-runtime | awk '{print $NF}' | while read i; do echo "---------"; echo "- Taring workspace and copying from $i"; docker exec $i bash -c 'date; du -sh /workspace/; rm -f /wk.tar 2> /dev/null; tar cvf /wk.tar /workspace/; du -sh /wk.tar'; DD=$(date +%Y%m%d-%H%M%S); docker cp $i:/wk.tar workspace-$i-$DD.tar; echo "gziping it"; gzip -9 workspace-$i-$DD.tar; du -sh workspace-$i-$DD.tar.gz; done
This will download the workspace to your local dir and gzip (-9) it.
Here is a multi-line version
# multi-line - command to export out entire workspace from all running openhands runtimes into tar ball
docker ps | grep openhands-runtime | awk '{print $NF}' | while read i; do
echo "---------";
echo "- Taring workspace and copying from $i";
docker exec $i bash -c 'date; du -sh /workspace/; rm -f /wk.tar 2> /dev/null; tar cvf /wk.tar /workspace/; du -sh /wk.tar';
DD=$(date +%Y%m%d-%H%M%S);
docker cp $i:/wk.tar workspace-$i-$DD.tar;
echo "gziping it";
gzip -9 workspace-$i-$DD.tar;
du -sh workspace-$i-$DD.tar.gz;
done