# Give the container access to your SSH folder. Copy to compose.ssh.yaml, keep the # block for your platform, then run: # # docker compose -f compose.yaml -f compose.ssh.yaml up --build # # What this grants: the container can read your SSH folder and use your # ssh-agent while it runs. The folder is mounted read-write so the in-app # "Connect a server" setup (Ctrl+K) can create a key and add a server to # known_hosts. It only appends to known_hosts after you confirm the fingerprint, # never replaces a changed key, and never overwrites an existing key file. # Prefer read-only? Add `:ro` to the folder mount; the setup's "trust" and # "create key" steps then fail and you manage those with ssh yourself. # # Make sure the folder exists first (`mkdir ~/.ssh`), or Docker creates it as root. services: app: environment: SSH_DIR: /ssh KNOWN_HOSTS_FILE: /ssh/known_hosts SSH_AUTH_SOCK: /ssh-agent.sock volumes: - ~/.ssh:/ssh # Linux: forward your running ssh-agent (make sure SSH_AUTH_SOCK is set). - ${SSH_AUTH_SOCK:-/dev/null}:/ssh-agent.sock # macOS with Docker Desktop: use the forwarded agent instead of the line above. # - /run/host-services/ssh-auth.sock:/ssh-agent.sock # Windows with Docker Desktop: the Windows OpenSSH agent cannot be forwarded, # so delete the agent line above. Keys without a passphrase work as key # files; the setup creates one for you (paths look like /ssh/_ed25519).