給定一個集裝箱正在運行的測功機,什麼是相當於docker exec -it blarg /bin/bash
的Heroku?也就是說,如何將shell打開到已經運行的容器中?Shell運行在Heroku dyno上的Docker容器。怎麼樣?
例Dockerfile:
FROM heroku/heroku:16
CMD while true; do sleep 1; done
運行示例:
$ heroku container:push my_app
<wait a minute>
$ heroku ps
=== my_app (Free): /bin/sh -c while\ true\;\ do\ sleep\ 1\;\ done (1)
my_app.1: up 2017/10/09 12:13:07 -0600 (~ 4m ago)
到目前爲止好。
但是現在......
$ heroku ps:exec --dyno=my_app.1
Establishing credentials... error
▸ Could not connect to dyno!
▸ Check if the dyno is running with `heroku ps'
良好的措施我檢查heroku ps
在這一點上,它表明測功機仍在運行。
是的,我已經完成了Heroku建議的所有事情to enable Docker support。根據文檔,我嘗試使用我選擇的基本映像,同時確保存在bash
,curl
,和python
。我也嘗試使用Heroku-16基本圖像,如上例所示。
(鏈接的文檔還引用了私人地點所需的步驟由於我沒有使用私人地點我沒有應用這些步驟。)
如果僅僅用'bash'的符號鏈接替換'sh',我會感到驚訝。如果作爲'sh'被調用,'bash'進入一個posix兼容模式(https://manpages.debian.org/stretch/bash/bash.1.en.html),它不支持'進程替換'(https:///www.gnu.org/software/bash/manual/html_node/Process-Substitution.html)。 'heroku-exec.sh'使用進程替換('... <(curl ...)')。 '$/bin/bash -c「cat <(echo 1)」' '$/bin/sh - '$ rm/bin/sh && ln -s/bin/c「cat <(echo 1)」' – wwerner
在heroku-exec腳本中添加'set + o posix'可能會有所幫助。 – wwerner