docker - 具有find -exec选项的docker exec(查找: `-exec'缺少参数)

标签 docker docker-compose

我正在尝试在Windows 10企业版上以管理员身份运行docker命令:

docker-compose exec --user magento2 web find /var/www/sample-data -type d -exec chmod g+ws {} \;

但我得到了错误:
find: missing argument to `-exec'

我试图通过使用''或“”逃脱:
docker-compose exec --user magento2 web "find /var/www/sample-data -type d -exec chmod g+ws {} \;"
但它抛出一个异常
rpc error: code = 2 desc = oci runtime error: exec failed: container_linux.go:262: starting container process caused "exec: \"find /var/www/sample-data -type d -exec chmod g+ws {} \\\\;\": sta t find /var/www/sample-data -type d -exec chmod g+ws {} \\;: no such file or directory"
我该如何解决这个问题?通常,当我将此命令插入容器时-一切正常。

最佳答案

使用sh代替:

docker-compose exec --user magento2 web sh -c 'find /var/www/sample-data -type d -exec chmod g+ws {} \;'

关于docker - 具有find -exec选项的docker exec(查找: `-exec'缺少参数),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44826054/

相关文章:

linux - 如何配置拇指安全性?

php - 尝试在 Docker 官方镜像中将 freetype 添加到 php-gd

postgresql - 使用Docker-compose,如何通过容器和主机中的相同端口访问容器数据库

docker - docker ubuntu镜像中的chrome路径是什么

django - docker-compose 有两个容器 : web can not connect to db

python - 使用 OpenCV 4.5.1 打开 VideoStream 可在 Windows 上运行,但在 Docker python :3. 9.2-slim-buster 上针对特定 IP cam 失败

linux - 在 Debian 11 上安装 Docker Desktop 后 docker-compose 停止工作

python - Django 静态文件未找到值错误

node.js - 无法通过 Docker 中的 node.js 连接到 MongoDB

mysql - Python MySQL Docker 连接