Skip to content

feat: Build Goose in a Docker Container#1551

Merged
ZhenLian merged 4 commits intomainfrom
zhen_docker_1
Mar 10, 2025
Merged

feat: Build Goose in a Docker Container#1551
ZhenLian merged 4 commits intomainfrom
zhen_docker_1

Conversation

@ZhenLian
Copy link
Copy Markdown
Contributor

@ZhenLian ZhenLian commented Mar 6, 2025

Description

This update partially addresses issue #1072, where users requested the ability to build and run Goose in a Docker container. Since users may have different use cases for using Docker, I've added a discussion thread to explore additional use cases and allow users to contribute their own. This update also includes a brief guide on how to build Goose within a Docker container.

Testing

I tested this on my local laptop.

  1. When running the Goose CLI in the docker container, you can observe the following:
    goose1

  2. On the first run of goose config, you select the API key settings:
    goose2

  3. On the second run of goose config, you choose the extension settings (I selected the developer tool).
    goose3

  4. Running goose session will then initiate a Goose session with developer tool capabilities.
    goose4

@ZhenLian ZhenLian marked this pull request as ready for review March 6, 2025 16:13
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 6, 2025

PR Preview Action v1.6.0

🚀 View preview at
https://block.github.io/goose/pr-preview/pr-1551/

Built to branch gh-pages at 2025-03-07 16:00 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

Copy link
Copy Markdown
Contributor

@lily-de lily-de left a comment

Choose a reason for hiding this comment

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

thanks for the documentation! 🙏

@yingjiehe-xyz
Copy link
Copy Markdown
Contributor

Thanks for the contribution! Have you tried run goose with custom extensions?

rm -rf /var/lib/apt/lists/*

# Install common development tools
RUN apt-get update && apt-get install -y \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

do we want to install uv as well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Certainly! I included a line to install uv and verified within the Docker container that it is properly installed.

# Preserve git author info
- GIT_AUTHOR_NAME=${GIT_AUTHOR_NAME:-Goose User}
- GIT_AUTHOR_EMAIL=${GIT_AUTHOR_EMAIL:[email protected]}
# Set GOOGLE_API_KEY to your own API key
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should we ignore the env variable here? I think it would be better to set it via goose configure

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, there are some nuances here. Docker operates in a headless environment, and it lacks certain built-in packages for user display. When we attempt to set and save the key into the keyring using goose configure, we will encounter this error:

Error Failed to access secure storage: Platform secure storage failure: DBus error: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11 
  Please check your system's secure storage and run 'goose configure' again. 
  If your system is unable to use secure storage, please try setting secret key(s) via environment variables.

In the Dockerfile, I've included a script to try installing DBus, but it hasn't worked yet. I'll continue monitoring this issue, and if I find a solution for storing this in the keyring, I'll update the code and instructions accordingly!

- SSH_AUTH_SOCK
stdin_open: true
tty: true
entrypoint: ["/bin/bash"]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

does this override the goose-wrapper entrypoint and is that intentional?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch! The goose-wrapper entrypoint isn't being utilized. I've removed it and revised some of the wording.

Comment on lines +10 to +13
# Mount git config (optional)
- ~/.gitconfig:/home/goose/.gitconfig:ro
# Mount SSH keys (optional)
- ~/.ssh:/home/goose/.ssh:ro
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

how are these defined as optional? wouldn't this always mount the directories via docker compose?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, my goal was to inform users that the volume mounting configurations are adjustable - they can decide whether to comment out those lines. That seems to be confusing though. I removed the optional wording, as users can simply read the code and remove those lines if necessary.

@kalvinnchau kalvinnchau changed the title Build Goose in a Docker Container feat: Build Goose in a Docker Container Mar 6, 2025
Copy link
Copy Markdown
Collaborator

@michaelneale michaelneale left a comment

Choose a reason for hiding this comment

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

the dockerfile and compose should be in docs dir, not root, as they are for illustration purposes is that right?

@ZhenLian
Copy link
Copy Markdown
Contributor Author

ZhenLian commented Mar 7, 2025

the dockerfile and compose should be in docs dir, not root, as they are for illustration purposes is that right?

Sure, I moved them to the docs folder and updated the instructions for how to compile them.

@ZhenLian
Copy link
Copy Markdown
Contributor Author

ZhenLian commented Mar 7, 2025

Have you tried run goose with custom extensions?

Not yet. My goal was to create a basic Docker template file to help users understand how to build Docker images from it. Once they're connected to the container, they have the freedom to add additional dependencies or custom extensions as they wish.
That being said, if there are any particularly useful extensions, I'd be glad to test them and add them to the documentation (so far, I've only worked with the built-in extensions :)). Given that Docker runs in a headless environment, some extensions might not be as advantageous as others. Maybe we could wait until a user specifically requests an extension?

@ZhenLian
Copy link
Copy Markdown
Contributor Author

ZhenLian commented Mar 7, 2025

@kalvinnchau @michaelneale @yingjiehe-xyz
Cool, I think I've addressed all your comments above. Could I ask for another review of this PR? Thank you very much!

Copy link
Copy Markdown
Collaborator

@michaelneale michaelneale left a comment

Choose a reason for hiding this comment

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

thanks!

@ZhenLian
Copy link
Copy Markdown
Contributor Author

@yingjiehe-xyz @michaelneale Awesome, thanks for the review!
@kalvinnchau I am merging this, but if you happen to spot anything in the future, feel free to let me know - happy to submit a fix in a supplemental PR after this!

@ZhenLian ZhenLian merged commit 9004c19 into main Mar 10, 2025
4 checks passed
@ZhenLian ZhenLian deleted the zhen_docker_1 branch March 10, 2025 16:20
michaelneale added a commit that referenced this pull request Mar 11, 2025
* main:
  feat: enable smart approve for user by default (#1599)
  ui: fix modal state (#1598)
  ui: setting configuration (#1597)
  fix: merge error logging in goose bench  (#1545)
  feat: add additional goosebench evals (#1571)
  chore: update types and imports (#1594)
  Retain session through view changes (#1580)
  docs: Add steps for desktop tutorial (#1590)
  remove env vars from bottom menu model setting (#1584)
  Fix Goosehints modal UI (#1581)
  docs: typo fix (#1593)
  feat: update config endpoints for use with providers (#1563)
  fix: update anthropic provider headers (#1592)
  feat: Build Goose in a Docker Container (#1551)
  docs: voyp blog post (#1588)
@evangineer
Copy link
Copy Markdown

I'm working on integrating Goose with a multi-Docker Compose setup, and have been puzzled by the line below.

- OOSE_HOME=/root/.goose

Is it a typo and why can't I find any info at all for either OOSE_HOME or GOOSE_HOME in the docs, the repo and the discord?

- OOSE_HOME=/root/.goose

@blevz
Copy link
Copy Markdown

blevz commented Apr 27, 2025

Yup, this satisfies the thrust of my request. Tysm

cbruyndoncx pushed a commit to cbruyndoncx/goose that referenced this pull request Jul 20, 2025
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.

7 participants