Setup (inside docker container)
nano ~/.bashrc
pkill ssh-agent
eval $(ssh-agent) > /dev/null
ssh-add ~/.ssh/id_rsa
Mount or Copy Keys
You have two options:
- Mount the SSH agent socket (recommended): Docker uses your running agent, no keys inside the container.
- Copy keys manually (less secure): place
id_rsainside the container, but remove it afterwards.
Usage
docker build --ssh default -t myapp .
Now private Git dependencies are available during build.