Skip to content

Instantly share code, notes, and snippets.

@sttk
Last active October 30, 2025 06:51
Show Gist options
  • Select an option

  • Save sttk/37d8eb2fe5ebf86b207235de30b18e17 to your computer and use it in GitHub Desktop.

Select an option

Save sttk/37d8eb2fe5ebf86b207235de30b18e17 to your computer and use it in GitHub Desktop.

Gemini CLI on docker container

1. Build a docker image for gemini-cli

1.1. Install gemini-cli

FROM node:24

RUN npm install -g @google/gemini-cli --ignore-scripts

USER node

WORKDIR /home/node
docker buildx build -t docker-gemini-setup .
docker run --name setup -it docker-gemini-setup bash

1.2. Login google for gemini-cli

NOTE 1:
This login method is for using the google-cli with a free license that uses a Google account. Please note that the free license is used for training AI models.

NOTE 2:
Since gemini-cli can also execute commands, using a Google account linked to other services might cause it to unintentionally access those services. Therefore, it is better to create a new, dedicated Google account for authentication.

- https://github.com/google-gemini/gemini-cli/blob/main/docs/get-started/authentication.md
- https://github.com/google-gemini/gemini-cli/blob/main/docs/tos-privacy.md

node@containerid:/# gemini
(Select `Login with Google` as the authentication method.)
(Since gemini-cli will terminate temporarily, restart it again.)
node@containerid:/# gemini
(Open the displayed URL in your local browser and allow gemini-cli to use your Google account.)
(Copy and paste the key displayed in the browser into the prompt where gemini-cli is waiting for input.)
(Once authentication is successful, gemini-cli will be available for use.)

1.3. Save the current container state as a Docker image

On a different terminal, create a Docker image from the current container's state.

docker commit setup docker-gemini:latest

After exiting the Docker container, delete the container used for setup.

docker rm setup

2. Create Rust development environment

2.1. Install Rust

FROM docker-gemini

USER root

RUN apt-get update -yq && apt-get install -yq curl build-essential

USER node

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y

ENV PATH="/home/node/.cargo/bin:$PATH"

RUN cargo install cargo-llvm-cov && \
    cargo install cargo-msrv --locked

WORKDIR /home/node/workspace
docker buildx build -f Dockerfile_rust -t docker-gemini-rust .

2.2. Run docker-gemini-rust with local directory synchronization

docker run --name gemini-rust -v ./:/home/node/workspace -it docker-gemini-rust bash

3. Create Golang development environment

3.1. Install Golang

FROM docker-gemini

USER root

RUN apt-get update -yq && apt-get install -yq curl build-essential

RUN curl -OL https://go.dev/dl/go1.25.1.linux-amd64.tar.gz && \
    tar -C /usr/local -xzf go1.25.1.linux-amd64.tar.gz

USER node

ENV PATH="/usr/local/go/bin:$PATH"

WORKDIR /home/node/workspace
docker buildx build -f Dockerfile_go -t docker-gemini-go .

3.2. Run docker-gemini-go with local directory synchronization

docker run --name gemini-go -v ./:/home/node/workspace -it docker-gemini-go bash

4. Create Java development environmet

4.1. Install Java

FROM docker-gemini

USER root

RUN apt-get update -yq && apt-get install -yq curl build-essential

USER node

WORKDIR /home/node

RUN curl -OL https://download.oracle.com/graalvm/25/latest/graalvm-jdk-25_linux-x64_bin.tar.gz && \
    tar -xzf graalvm-jdk-25_linux-x64_bin.tar.gz

ENV PATH=/home/node/graalvm-jdk-25+37.1/bin:$PATH

WORKDIR /home/node/workspace
docker buildx build -f Dockerfile_java -t docker-gemini-java .

4.2. Run docker-gemini-java with local directory synchronization

docker run --name gemini-java -v ./:/home/node/workspace -it docker-gemini-java bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment