我試圖在碼頭集裝箱內運行lektor,並遇到問題。如何在Docker容器中運行Lektor?
如果我在我的Dockerfile中添加了我的源代碼文件夾,那麼一切正常,但是當然,容器不是動態的,並且不會響應代碼中的更改。
如果我使用卷,容器變爲動態,並且lektor在我進行更改時成功重建併爲我的網站提供服務。
然而,當我來到發佈現場,出現在容器中的日誌中的錯誤,並進入一個永無休止的循環:
Started build Debugging middleware caught exception in streamed response at a point where response headers were already sent. Traceback (most recent call last): File "/usr/local/lib/lektor/lib/python2.7/site-packages/lektor/admin/utils.py", line 18, in generate for event in chain(f(*args, **kwargs), (None,)): File "/usr/local/lib/lektor/lib/python2.7/site-packages/lektor/admin/modules/api.py", line 309, in generator for event in event_iter: File "/usr/local/lib/lektor/lib/python2.7/site-packages/lektor/publisher.py", line 639, in publish self.link_artifacts(path) File "/usr/local/lib/lektor/lib/python2.7/site-packages/lektor/publisher.py", line 602, in link_artifacts link(full_path, dst) OSError: [Errno 18] Invalid cross-device link
最小Dockerfile:
FROM python:2.7.11
RUN curl -sf https://www.getlektor.com/install.sh | \
sed '/stdin/d;s/input = .*/return/' | \
sh
我實際上是在使用docker-compose。
最小的碼頭工人,compose.yml: version: '2' services: web: build: . ports: - "5000:5000" volumes: - .:/project working_dir: /project/source command: ['lektor', 'server', '--host', '0.0.0.0.']
(我的項目文件夾的結構使得LEKTOR項目文件和所有預期LEKTOR文件夾中的「源」子文件夾)。
「無效的跨設備鏈接」的快速谷歌顯示與符號鏈接的東西。 Lektor在發佈時做了什麼(我聽說過但沒有使用它)?它有可能試圖在容器和容器中的東西之間創建符號鏈接?那裏可能有問題?也許權限。似乎開始的地方。 – johnharris85
是的,lektor試圖使用鏈接,它不喜歡卷的安裝方式。 – Owen
看起來,構建過程使用硬鏈接,並且輸出文件夾不在源代碼路徑中。由於源代碼是已安裝的卷,並且構建文件夾位於容器中的其他位置,因此兩個文件系統不同,硬鏈接失敗。 – Owen