6

docker exec命令中含有通配符执行失败的问题

 2 years ago
source link: https://wiki.eryajf.net/pages/1cb90e/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

docker exec命令中含有通配符执行失败的问题原创

我写的go-ldap-admin (opens new window)的demo环境是通过docker-compose一键拉起的。

因为服务器部署,与本地拉起测试有一些配置需要调整,于是打算用脚本做一下,这个时候发现执行带有通配符的命令会报如下错误:

$ docker exec -it go-ldap-admin-ui  ls static/js/app.*.js
ls: cannot access static/js/app.*.js: No such file or directory

一开始想着加个单引号把命令包起来,发现仍然不行。

解决方案:用双引号将命令包裹起来,就不会报错了。

$ docker exec -it go-ldap-admin-ui sh -c  "ls static/js/app.*.js"
static/js/app.580a29c6.js
8647d5b91f458b86.png

参考:https://stackoverflow.com/questions/50742892/using-in-docker-exec-command (opens new window)


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK