-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
docs: improve custom sandbox guide with detailed requirements and examples #5268
docs: improve custom sandbox guide with detailed requirements and examples #5268
Conversation
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Ensure we're running as root | ||
USER root |
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.
I think we change to a openhands specific user, but we need to confirm this is a requirement to exit the build as root.
``` | ||
|
||
Save this file in a folder. Then, build your Docker image (e.g., named custom-image) by navigating to the folder in | ||
the terminal and running:: | ||
Save this file as `docker/runtime.Dockerfile`. Then, build your Docker image using one of these methods: |
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.
we should probably note that a nested docker/ dir is not required.
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.
Not sure if we want to take into account people that might not be too familiar with docker and dockerfiles.
In the previous version, it said to navigate to the folder in the terminal and then run the command. In the new version, it doesn't specify where to run the command from.
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.
@mamoodi sounds like you want a flattened example. I'm fine with that. Let's update the documentation so that we don't have any nested directory structures.
|
||
First, ensure you can run OpenHands by following the instructions in [Development.md](https://github.com/All-Hands-AI/OpenHands/blob/main/Development.md). | ||
- `SANDBOX_RUNTIME_CONTAINER_IMAGE`: Specifies the custom runtime image (e.g., `local/runtime:latest`) |
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.
Let's add a note here around SANDBOX_BASE_CONTAINER_IMAGE
and the differences here.
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.
Agree, as a newcomer I find this confusing. This is what I found out after lots of trial and error:
- I could only get the custom sandbox image to work using the development workflow outside docker, e.g.
make run
. - Setting
SANDBOX_RUNTIME_CONTAINER_IMAGE
together with docker compose does not result in a working agent, it's like lots of things are missing from the image - Setting
SANDBOX_BASE_CONTAINER_IMAGE
together with docker compose fails with docker not being available when building the runtime image - The only way to get the custom sandbox image to work together with docker compose was to first set the custom image as base image in config.toml, start openhands using
make run
and then look for the logs showing what the runtime image was built and tagged as, then copying that image reference toSANDBOX_RUNTIME_CONTAINER_IMAGE
. Then, using docker compose would result in a openhands agent using the custom runtime image
|
||
```dockerfile | ||
FROM debian:latest | ||
|
||
# Install required packages | ||
RUN apt-get update && apt-get install -y ruby | ||
RUN apt-get update && apt-get install -y \ |
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.
maybe we should note that this should be specific to the users wants. A common one might be installing the GH cli here.
|
||
## Using the Development Workflow |
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.
We should keep the "Development workflow" section intact. Let's note that this is specific for development of/on OpenHands, and not specific to "development using OpenHands" which are distinct.
@@ -12,53 +12,131 @@ You have two options for customization: | |||
1. Use an existing image with the required software. | |||
2. Create your own custom Docker image. | |||
|
|||
If you choose the first option, you can skip the `Create Your Docker Image` section. | |||
## Important Requirements |
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.
This section is really nice
the terminal and running:: | ||
Save this file as `docker/runtime.Dockerfile`. Then, build your Docker image using one of these methods: | ||
|
||
### Method 1: Direct Docker Build |
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.
This may be a personal thing but the Method 1
and Method 2
do different things. One of them just builds the custom docker image and the other actually runs everything. I would just keep the Method 1
and show the user how to build it.
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.
The other problem with the docker compose is it has OpenHands version which again is another place that needs to be continuously updated. Also it has other configurations that get passed into the docker command. If that command ever changes, this would need to be updated too.
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.
Good points.
- Let's add a comment in the docker-compose to check the require variables that can be passed. This should link to the docs that explain the variables available.
- Let's add a command to the docker build (Method 1) that links to the explanation on how to run the command and specify how to pass in the newly built docker-image as the runtime image.
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.
Agree to just keep Method 1 and then include instructions on how to set the SANDBOX_RUNTIME_CONTAINER_IMAGE env var (maybe also the equivalent config.toml setting) when running openhands.
|
||
### Setup | ||
### Environment Variables |
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.
This section's information doesn't really add anything for this procedure.
The variable SANDBOX_RUNTIME_CONTAINER_IMAGE doesn't get used if I understand correctly.
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.
Let's remove this section.
|
||
## Common Issues and Troubleshooting |
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.
I would move this section above ## Security Considerations
.
- Verify environment variable settings | ||
- Check volume mount permissions | ||
|
||
## Testing Your Custom Sandbox |
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.
This section should be moved right after Create You Docker Image
. However, it should have instructions on how to actually use the custom image. Either in development workflow or with the docker command through the README. Ideally without actually copy pasting the docker command.
Hi! Shall we get this merged? |
|
||
For example, if you want OpenHands to have `ruby` installed, create a `Dockerfile` with the following content: | ||
Here's a complete example of a custom runtime Dockerfile: | ||
|
||
```dockerfile | ||
FROM debian:latest |
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.
FROM debian:latest | |
FROM nikolaik/python-nodejs:python3.12-nodejs22 |
Rationale: Using the same base as the default sandbox image and just adding ruby makes it a bit more easy to get the right versions of python and node are being installed in the runtime image, rather than relying on the python and node versions that are included in debian:latest
RUN apt-get update && apt-get install -y ruby | ||
RUN apt-get update && apt-get install -y \ | ||
ruby \ | ||
python3 \ |
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.
If using the default sandbox image in the FROM clause, we don't need to add python3 or nodejs here
|
||
First, ensure you can run OpenHands by following the instructions in [Development.md](https://github.com/All-Hands-AI/OpenHands/blob/main/Development.md). | ||
- `SANDBOX_RUNTIME_CONTAINER_IMAGE`: Specifies the custom runtime image (e.g., `local/runtime:latest`) |
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.
Agree, as a newcomer I find this confusing. This is what I found out after lots of trial and error:
- I could only get the custom sandbox image to work using the development workflow outside docker, e.g.
make run
. - Setting
SANDBOX_RUNTIME_CONTAINER_IMAGE
together with docker compose does not result in a working agent, it's like lots of things are missing from the image - Setting
SANDBOX_BASE_CONTAINER_IMAGE
together with docker compose fails with docker not being available when building the runtime image - The only way to get the custom sandbox image to work together with docker compose was to first set the custom image as base image in config.toml, start openhands using
make run
and then look for the logs showing what the runtime image was built and tagged as, then copying that image reference toSANDBOX_RUNTIME_CONTAINER_IMAGE
. Then, using docker compose would result in a openhands agent using the custom runtime image
This PR is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
This PR improves the custom sandbox guide documentation by:
Adding a clear "Important Requirements" section highlighting:
Providing a complete example Dockerfile with multiple packages
Adding two methods for building and running:
Including detailed sections on:
This addresses issue #5266 by making the custom sandbox setup process more clear and comprehensive.
Changes include: