![](/img/trans.png)
[英]Unset ENV variables inside docker container through script which will be execute inside the same container
[英]Execute script inside docker container which is folder different than WORKDIR
我在我的docker容器里面:這是我的工作目錄
root@19b84a014662:/usr/src/ghost#
我有一個腳本:
root@19b84a014662:/
我能夠cd到/
並執行腳本。 但我需要從docker-compose文件中執行腳本。 我試過了
./test.sh
但這實際上意味着它在/usr/src/ghost/
搜索腳本而不是/
我如何在/
我的容器中執行腳本?
示例:我ssh到我的容器中:
root@19b84a014662:/usr/src/ghost# ls
Gruntfile.js LICENSE PRIVACY.md README.md config.example.js config.js content core index.js node_modules npm-shrinkwrap.json package.json
我的容器根目錄中有一個腳本。 我想用以下方法執行它:
./test.sh
比它只顯示/usr/src/ghost
文件夾/腳本而不是/
root@19b84a014662:/usr/src/ghost# ./
content/ core/ node_modules/
只需將./test.sh
替換為
/test.sh
因為./
表示你從當前目錄開始(在這種情況下是工作目錄/usr/src/ghost/
)。 盡管如此/
意味着你從根目錄開始,這就是你想要做的。
或者,您可以使用下面的&&
concatenator切換到root目錄並在一個命令中執行腳本。 但我會推薦以上內容。
cd / && ./test.sh
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.