Zechariah Lvov
Zechariah Lvov

Reputation: 175

invalid empty ssh agent socket, make sure SSH_AUTH_SOCK is set How to set SSH_AUTH_SOCK for docker build?

I'm trying to deploy a docker-compose app in PyCharm, Windowsb10. Running the command:

set "DOCKER_BUILDKIT=1" && docker build --ssh default=${SSH_AUTH_SOCK} -f docker/Dockerfile -t basketball_backend_api_core .

Results in:

could not parse ssh: [default=]: invalid empty ssh agent socket, make sure SSH_AUTH_SOCK is set

Where should I set the SSH_AUTH_SOCK?

UPD: Status of my OpenSSH Authentication Agent is running

Upvotes: 7

Views: 20358

Answers (1)

Schonfinkel
Schonfinkel

Reputation: 809

It seems that either the --ssh argument doesn't accept empty values as an argument.

eval $(ssh-agent)
set "DOCKER_BUILDKIT=1" && docker build --ssh default=${SSH_AUTH_SOCK} -f docker/Dockerfile -t basketball_backend_api_core .

or you may need to run ssh-add to add private key identities to the authentication agent first for this to work.

before_script:
  ##
  ## Install ssh-agent if not already installed, it is required by Docker.
  ## (change apt-get to yum if you use an RPM-based image)
  ##
  - 'command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )'

  ##
  ## Run ssh-agent (inside the build environment)
  ##
  - eval $(ssh-agent -s)

  ##
  ## Add the SSH key stored in SSH_PRIVATE_KEY variable to the agent store
  ## We're using tr to fix line endings which makes ed25519 keys work
  ## without extra base64 encoding.
  ## https://gitlab.com/gitlab-examples/ssh-private-key/issues/1#note_48526556
  ##
  - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -

from Gitlab's docs.

Upvotes: 7

Related Questions