瀏覽代碼

Первая работающая версия

wadim 7 年之前
父節點
當前提交
66208bdb32
共有 2 個文件被更改,包括 21 次插入0 次删除
  1. 4 0
      Dockerfile
  2. 17 0
      docker-entrypoint.sh

+ 4 - 0
Dockerfile

@@ -0,0 +1,4 @@
+FROM docker:stable-dind
+
+ENTRYPOINT ["/docker-entrypoint.sh"]
+COPY docker-entrypoint.sh /

+ 17 - 0
docker-entrypoint.sh

@@ -0,0 +1,17 @@
+#!/bin/sh
+
+trap cleanup SIGTERM
+
+cleanup()
+{
+  echo Terminating $SERVICENAME
+  docker rm -f $(docker ps -q -f label=ru.sdsys.subcontainer=$SERVICENAME)
+}
+
+SERVICENAME=$(docker inspect $HOSTNAME -f "{{index .Config.Labels \"com.docker.swarm.service.name\"}}")
+
+echo Starting $SERVICENAME
+
+exec "docker" "run" "-l" "ru.sdsys.subcontainer=$SERVICENAME" "$@" &
+
+wait