Skip to content

Docker

SSH access

Make your SSH keys visible to the SSH agent:

# Linux
ssh-add -K

# macOS
ssh-add --apple-use-keychain

Verify your keys are visible to the SSH agent:

ssh-add -L

Define a RUN command in Dockerfile which should have access to your SSH keys:

RUN --mount=type=ssh <COMMAND>

Build:

docker build --ssh default .

Or use Docker Compose (v2):

services:
  my-service:
    build:
      dockerfile: Dockerfile
      context: .
      ssh:
        - default

  ...