Skip to content

Dockerfile best practice: add --no-install-recommends to apt-get install commands in agent-server Dockerfile #5049

Description

@neubig

Context

The Dockerfile at openhands-agent-server/openhands/agent_server/docker/Dockerfile has two apt-get install commands that do not use the --no-install-recommends flag:

  1. Docker Engine install (line ~380): apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
  2. GitHub CLI install (line ~419): apt-get install -y gh

Best practice

It is a Docker best practice to use --no-install-recommends with apt-get install to avoid pulling in unnecessary recommended packages. This keeps the image lean and reduces unnecessary bloat.

Suggested change

Add --no-install-recommends to both apt-get install commands:

# Docker Engine
apt-get install -y --no-install-recommends docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

# GitHub CLI
apt-get install -y --no-install-recommends gh

Acceptance criteria

  • Both apt-get install commands in the agent-server Dockerfile use --no-install-recommends
  • Docker image still builds and functions correctly

OpenHands AI triage

The following comments and acceptance criteria were added by the OpenHands AI agent.

Triage

This is a narrow Dockerfile hygiene fix. The agent-server Dockerfile at openhands-agent-server/openhands/agent_server/docker/Dockerfile has two apt-get install invocations that omit --no-install-recommends (Docker Engine: apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin; GitHub CLI: apt-get install -y gh), while the other two apt-get install invocations in the same file already pass the flag. Adding it drops apt's recommended-but-unneeded dependencies and shrinks the image without changing the requested packages.

Scope: add --no-install-recommends to exactly those two commands in that Dockerfile. Non-goals: no change to package names, versions, repositories, or pinning; no other Dockerfile restructuring; no edits to examples/02_remote_agent_server/06_custom_tool/Dockerfile; no changes for non-apt package managers (microdnf/dnf/yum); no behavior change beyond which packages apt installs.

Verification note: this is a packaging change, so a mocked or unit test cannot validate it. Evidence must come from a real image build plus smoke-running the installed docker and gh executables in the built image (or from the existing agent-server image-build CI job). Two open PRs already implement this (#5070, #5192); whichever is merged should satisfy these criteria.

Desired Behavior

The agent-server Docker image installs the Docker Engine packages and the GitHub CLI without apt's recommended dependencies, while still providing working docker / docker compose and gh executables, consistent with the other apt-get install invocations in the same Dockerfile.

Acceptance Criteria

  • The Docker Engine install in openhands-agent-server/openhands/agent_server/docker/Dockerfile reads apt-get install -y --no-install-recommends docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin, with the package list unchanged.
  • The GitHub CLI install in the same Dockerfile reads apt-get install -y --no-install-recommends gh.
  • Every apt-get install invocation remaining in that Dockerfile passes --no-install-recommends, and the diff is limited to adding the flag to those two commands (no other Dockerfile line changes).
  • The agent-server Docker image builds successfully from the modified Dockerfile, locally or via the existing agent-server image-build CI job, with no new build failure.
  • In the built image, docker --version, docker compose version, and gh --version all succeed, confirming the recommended-package removal did not drop a runtime requirement.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    dockerenhancementNew feature or requestpriority:lowFor bugs, affects only non-mainstream cases, or is annoying but with a clear workaround.ready-for-devIssue meets development readiness criteria

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions