简体   繁体   English

调用 python 脚本运行 docker-compose ubuntu 时权限被拒绝

[英]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:我需要运行 python 脚本才能运行命令: docker-compose restart ,但我得到了:

dc restart: 1: /root/chat-9: Permission denied dc 重启:1:/root/chat-9:权限被拒绝

and this my python code:这是我的 python 代码:

#!/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'.注意: dc是 'docker-compose' 的别名。

I had change chmod 777 -R for folder chat-9 also, but not working,我也为文件夹 chat-9 更改了 chmod 777 -R,但没有工作,

How to set permission so that python able to run docker-compose?如何设置权限使 python 能够运行 docker-compose?

please help请帮忙

Thanks谢谢

Additionally, use sudo chmod +x <your_filename> to make it executable.此外,使用sudo chmod +x <your_filename>使其可执行。

Use: sudo chown -R $USER <your_file> to change the ownership from root to a user.使用: sudo chown -R $USER <your_file>将所有权从root更改为用户。 $USER is the username. $USER是用户名。

I found it after I do sudo chmod 755 root and do sudo chown from root to www-data我在执行 sudo chmod 755 root 并从 root 到 www-data 执行 sudo chown 后找到了它

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 Ubuntu 虚拟机上使用 docker-compose 运行时,Python 脚本无法访问用户主位置的目录 - Python script not able to access the directory at user home location when run using docker-compose on Ubuntu virtual machine 如何在 docker-compose 之后在 shell 脚本中运行 python 文件? - How to run python file after docker-compose in a shell script? PermissionError: [WinError 5] Access Denied: [4776] 运行 docker-compose up 时无法执行脚本 docker-compose - PermissionError: [WinError 5] Access Denied: [4776] Failed to execute script docker-compose when running docker-compose up 运行 docker-compose 时出现权限错误 - When running docker-compose, I get a permission error 在运行 MySQL 服务器的 docker-compose 中重新运行 Python 脚本 - re-run Python script in started in docker-compose with MySQL server running 当我尝试 docker-compose 时无法执行脚本 docker-compose - Failed to execute script docker-compose when I try docker-compose up 当用docker-compose run调用但gunicorn可以工作,但不能通过docker-compose up调用 - gunicorn works when called with docker-compose run but not docker-compose up /var/run/docker.sock:在Python CGI脚本中运行docker时权限被拒绝 - /var/run/docker.sock: permission denied while running docker within Python CGI script docker-在运行python Scheduler脚本时在附加上卡住 - docker-compose up stucks on attaching to when running an python scheduler script 使用 docker-compose up 运行时,如何优雅地停止 Dockerized Python ROS2 节点? - How to gracefully stop a Dockerized Python ROS2 node when run with docker-compose up?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM