0
使用docker-compose
和python:2.7
時,它僅在單獨執行while 1
循環和time.sleep(1)
時正常運行。docker在執行python循環中的time.sleep(1)時出現問題
但是它們在執行它們時會發生混淆。
這裏是泊塢窗版本和文件內容在我的mac
tmp docker -v
Docker version 1.12.5, build 7392c3b
tmp cat docker-compose.yml
version: '2'
services:
test:
image: python:2.7
command: [python, -c, "print 0\nwhile 1:\n\tprint 1\n\tbreak"]
tmp docker-compose up
Creating network "tmp_default" with the default driver
Creating tmp_test_1
Attaching to tmp_test_1
test_1 | 0
test_1 | 1
tmp_test_1 exited with code 0
tmp cat docker-compose.yml
version: '2'
services:
test:
image: python:2.7
command: [python, -c, "print 0\nimport time\nprint time.sleep(1)"]
tmp docker-compose up
Recreating tmp_test_1
Attaching to tmp_test_1
test_1 | 0
test_1 | None
tmp_test_1 exited with code 0
tmp cat docker-compose.yml
version: '2'
services:
test:
image: python:2.7
command: [python, -c, "print 0\nimport time\nwhile 1:\n\tprint time.sleep(1)"]
tmp docker-compose up
Recreating tmp_test_1
Attaching to tmp_test_1
,並在這裏stucks。
希望知道原因和解決方法,謝謝。
它的工作原理。在Python的手冊頁中有關於內部緩衝的細節。謝謝。 – Roy