Execute git commands from container to host

  docker, git, ssh, ubuntu

I would like to run git commands from my container to the host. The git folder I’m updating lives on the host machine and I’m unable to clone it in my container. I would also prefer to have the files in my host machine so users don’t have a hard time uploading files.

  • Host
    • DockerContainer 1

Things I tried:

  ssh -i /var/sshkeys [email protected] 'cd /var/www/scheduledqueries && git pull' 

I got an error upon entering my code:

 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 @         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 Permissions 0755 for '/var/sshkeys' are too open.
 It is required that your private key files are NOT accessible by others.
 This private key will be ignored.
 Load key "/var/sshkeys": bad permissions
 [email protected]'s password:
 Permission denied, please try again.
 [email protected]'s password:
 error: cannot open .git/FETCH_HEAD: Permission denied

 [email protected]:/#

I copied my cert and keys files to a location and listed it in the volume section of my docker-compose

Source: Docker Questions

LEAVE A COMMENT