permission denied when call python script to run docker-compose ubuntu
I need to run python script just to run command : docker-compose restart, but I got :
dc restart: 1: /root/chat-9: Permission denied
and this my python code :
#!/usr/bin/python import subprocess from pathlib import Path home_path = str(Path.home()) docker_path = Path(home_path+'/chat-9') p = subprocess.Popen([docker_path,'dc restart'],shell=True) p.wait()
note : dc is aliases from ‘docker-compose’.
I had change chmod 777 -R for folder chat-9 also, but not working,
How to set permission so that python able to run docker-compose?
please help
Thanks
Additionally, use sudo chmod +x <your_filename>
to make it executable.
Use : sudo chown -R $USER <your_file>
to change the ownership from root
to a user. $USER
is the username.