0

I am creating a python script to run a docker image. I am using the command:

client.containers.run("-p 9000:9000 -p 8000:8000 -t -i bamos/openface /bin/bash", "echo hello world")

Python returns an error message:

ConnectionError: ('Connection aborted.', error(13, 'Permission denied'))

this is an understood error since the command requires a sudo prefix then it prompts a password.

My question here is how to run sudo-based commands in python and how to insert the required password within the code.

1

2 Answers 2

1

You actually don't need a sudo for this command. Most likely reason you are getting this error is because you don't have access to the docker socket. All you need to do is to add yourself to the docker group. Make sure you log out and log back in after you do that.

Running things as root via sudo or some other means is bad security practice.

Sign up to request clarification or add additional context in comments.

1 Comment

You can do this with sudo adduser `whoami` docker on Debian flavored distributions. Afterwards you have to recreate your login session since group associations are only refreshed on login.
0

You need to add user to the docker group as follows,

 usermod -aG docker $SUDO_USER

 Ex:
 usermodel -aG docker ubuntu

Please do exit and ssh back in after adding the user

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.