Skip to content
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

Install docker in the OpenHands app image #4283

Merged
merged 10 commits into from
Oct 10, 2024
Merged

Install docker in the OpenHands app image #4283

merged 10 commits into from
Oct 10, 2024

Conversation

mamoodi
Copy link
Collaborator

@mamoodi mamoodi commented Oct 9, 2024

End-user friendly description of the problem this fixes or functionality that this introduces

  • Include this change in the Release Notes. If checked, you must provide an end-user friendly description for your change below

Install docker in the OpenHands app image


Give a summary of what the PR does, explaining any non-trivial design decisions

Installing docker in the OpenHands app image allows it to build a sandbox image off of a SANDBOX_BASE_CONTAINER_IMAGE using the docker method. So users are able to provide a base image to the docker command without the development flow.

I tested this by:

  • Building the OpenHands app image and tagging it with myapp:1.0.0
  • Running the docker command as follows:
docker run -it \                                         
    -e SANDBOX_BASE_CONTAINER_IMAGE=ruby:3.3.4 \
    -e SANDBOX_USER_ID=$(id -u) \
    -e WORKSPACE_MOUNT_PATH=$WORKSPACE_BASE \
    -v $WORKSPACE_BASE:/opt/workspace_base \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -p 3000:3000 \
    --add-host host.docker.internal:host-gateway \
    --name openhands-app-$(date +%Y%m%d%H%M%S) \
    myapp:1.0.0 
  • Checking that ruby 3.3.4 is installed

I am unsure if this is the route we want to go. It seems to add 0.5GB to the app image. However, this is what I came up with after some guidance. See the issues for why this change is needed below. If this is fine, I can this method to the https://docs.all-hands.dev/modules/usage/how-to/custom-sandbox-guide doc


Link of any specific issues this addresses
#4220
#4230

@mamoodi mamoodi requested review from rbren and xingyaoww October 9, 2024 01:26
RUN apt install -y apt-transport-https ca-certificates gnupg \
&& curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker.gpg] https://download.docker.com/linux/debian bookworm stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null \
&& apt update \
Copy link
Collaborator

@tobitege tobitege Oct 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • is apt-update needed twice (see line 46)?
  • I don't recall OH is doing any of the signing operations, are these needed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was following this: https://linuxiac.com/how-to-install-docker-on-debian-12-bookworm/
But I can remove those and see how it goes. The apt update may be needed after we add that source but I'm not linux expert lol. Will try a few things

Copy link
Collaborator Author

@mamoodi mamoodi Oct 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tobitege followed the official docs now: https://docs.docker.com/engine/install/debian/

update is required for sure (tried it).
I'm guessing signing is required as well.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup after you add a new source you need to update

@tobitege
Copy link
Collaborator

tobitege commented Oct 9, 2024

Have you taken a look at this (recent contribution)? Looks very similar to your steps, maybe that helps:
https://github.com/All-Hands-AI/OpenHands/blob/main/containers/dev/Dockerfile

@mamoodi
Copy link
Collaborator Author

mamoodi commented Oct 9, 2024

Have you taken a look at this (recent contribution)? Looks very similar to your steps, maybe that helps: https://github.com/All-Hands-AI/OpenHands/blob/main/containers/dev/Dockerfile

That one seems to be installing the Ubuntu one: https://docs.docker.com/engine/install/ubuntu/
I checked the OpenHands app version and it's based off of Debian:

Distributor ID: Debian
Description:    Debian GNU/Linux 12 (bookworm)
Release:        12
Codename:       bookworm

So I followed that one.

Copy link
Collaborator

@xingyaoww xingyaoww left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great! Actually - can we add a quick test for this workflow? e.g., try to run docker run hello-world inside the APP image?

@rbren
Copy link
Collaborator

rbren commented Oct 9, 2024

test would definitely be nice to have!

@mamoodi
Copy link
Collaborator Author

mamoodi commented Oct 10, 2024

@rbren and @xingyaoww added test based on Xingyao's suggestion.

@mamoodi mamoodi merged commit 2d2d3cc into main Oct 10, 2024
@mamoodi mamoodi deleted the mh/docker-app branch October 10, 2024 12:21
@mamoodi mamoodi mentioned this pull request Oct 10, 2024
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants