question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ssh argument not working as expected

See original GitHub issue

I have been working on porting a bash script which I use to build some of my docker images to python, and your package has been a great help! I appreciate how easy and straightforward it is to port my docker run commands directly to python.

I just ran into an issue with the ssh arg though. Looks like when setting ssh=default in the docker.build() command, I see an error:

error: invalid empty ssh agent socket, make sure SSH_AUTH_SOCK is set

I checked, and that variable is set in my shell environment. Any suggestions? Am I using the argument incorrectly? The same bash script with --ssh default is working without problems.

Let me know if I can provide anything to help debug. Thanks!

    raise DockerException(
python_on_whales.utils.DockerException: The docker command executed was `/usr/bin/docker buildx build --build-arg FROM_TAG=gui-support --ssh default --file docker/ros/kinetic/autoyard-core/Dockerfile --tag ros-kinetic-autoyard-core:test --iidfile /tmp/tmpc9q55l8w/id_file.txt .`.
It returned with code 1

Logged the variable with print("SSH socket {}".format(os.environ['SSH_AUTH_SOCK'])) and can see that the variable is printed correctly, but the docker build command still fails:

SSH socket /run/user/1001/keyring/ssh
error: invalid empty ssh agent socket, make sure SSH_AUTH_SOCK is set

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
gabrieldemarmiessecommented, Apr 18, 2021

Thank you for this great bug report! Reading the code with this in mind, I understand what is wrong. Is right way to fix it is to have a dict and put os.environ inside, then put the custom environment variables inside. Something like

def run(..., env={}):
    subprocess_env = {}
    subprocess_env.update(os.environ)
    subprocess_env.update(env)
    subprocess.call(..., env=subprocess_env)

I noticed this bug before in the bake command and fixed it, but my fix wasn’t very good because it worked only for bake. I’ll make a fix today or tomorrow. Thanks again for making this package better!

0reactions
gabrieldemarmiessecommented, Apr 19, 2021

I’m happy that this package helps you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

expect not taking ssh arguments in while/for loop
I tried with single, double quotes and caret symbol still no luck. Here I want to execute remote command as argument like :...
Read more >
Expect with ssh not working every time - Stack Overflow
I created script with expect + ssh + bash executed command to automate some process on remote machine. Problem is that it is...
Read more >
SSHLibrary - Robot Framework
SSHLibrary is a Robot Framework test library for SSH and SFTP. This document explains how to use keywords provided by SSHLibrary.
Read more >
Expect Script SSH Example Tutorial - DigitalOcean
Hi there, I have a problem when trying to ssh to a solaris box using groovy script and expect To give you some...
Read more >
SSH EXEC not working to execute remote jar cmd - Ask Ubuntu
My local server is getting the jar logs instead of writing into nohup in the remote server and my jar is running but...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found