2017-01-10 43 views

回答

2

可以呀,你平時做的是

備選方案A:

創建一個busybox的圖像,並複製你的框架,暴露位置的體積VOLUME /opt/framework/

FROM alpine 
COPY framework /opt/framework 
VOLUME /opt/framework 
COPY busyscript.sh /usr/local/bin/busyscript 
RUN chmod +x /usr/local/bin/busyscript 
CMD ["busyscript"] 

雖然busyscript.sh看起來像

#!/bin/sh 
#set -x 

pid=0 

# SIGTERM-handler 
term_handler() { 
    if [ $pid -ne 0 ]; then 
    kill -SIGTERM "$pid" 
    wait "$pid" 
    fi 
    exit 143; # 128 + 15 -- SIGTERM 
} 

# setup handlers 
# on callback, kill the last background process, which is `tail -f /dev/null` and execute the specified handler 
trap 'kill ${!}; term_handler' SIGTERM 

echo "Started code" 
# wait forever 
while true 
do 
    tail -f /dev/null & wait ${!} 
done 

加入這一形象在你的碼頭工人,compose.yml服務,因爲讓說,「框架」,那麼,你希望他們消費的服務,您可以添加

volume_from 
    - framework:ro 

優點:

  • 你可以編譯,構建和部署負全部的framworks
  • 存在或多或少的不運行時開銷運行這個額外的容器

缺點:

  • 圖像尺寸overhead(高山,30MB)

備選方案B 你用你的服務爲一體的 「框架基地」 之一,可以說服務A,這意味着你在複製該服務的架構(2的一個消費它),並再次使用VOLUME /opt/framework揭露其作爲服務B卷

,以同樣的方式,裝入卷

serviceB: 
    volume_from 
    - serviceA:ro 

臨:

  • 沒有多餘的容器

缺點:

  • 框架需要與serviceA部署,無論服務A將需要更新
    • 你對A有依賴性,A需要更新,所有其他集裝箱需要重新分配
+0

太棒了!謝謝 –

相關問題