https://github.com/stelligent/git-ssh-build
Mount SSH Socket At Docker Build Time
https://github.com/stelligent/git-ssh-build
Last synced: 4 months ago
JSON representation
Mount SSH Socket At Docker Build Time
- Host: GitHub
- URL: https://github.com/stelligent/git-ssh-build
- Owner: stelligent
- License: mit
- Created: 2019-04-05T15:49:51.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2020-01-07T21:33:36.000Z (over 6 years ago)
- Last Synced: 2025-05-14T19:17:24.864Z (about 1 year ago)
- Language: Dockerfile
- Size: 1.95 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Git SSH Mount At Build
Example project of cloning a private repository during a docker build
> No SSH Keys are stored in the docker layers - EVER
Docker mounts your SSH socket into the container layer during build to perform
the steps that you specify using:
```
RUN --mount=type=ssh
```
[This article helps explain](https://medium.com/@tonistiigi/build-secrets-and-ssh-forwarding-in-docker-18-09-ae8161d066) more about what is happening.
## REQUIREMENTS
- Docker 18.09+
- SSH Agent on your host
- SSH Keys mounted in running SSH agent on host
- SSH access to the repository you wish to clone
## USAGE
Clone the repository and run
```
make run REPOSITORY=
```
> Replace repository_ssh_url with the git ssh path to your repository
## TROUBLESHOOTING
For whatever reason you need to explicitly add your ssh keys to your local SSH agent on MacOS. If you get a "Permission Denied, public key" error try running this on your host.
```
ssh-add ~/.ssh/id_rsa
```
This will add your default key to your ssh agent. Retry your `make run` command again.