docker-entrypoint.sh 445 B

123456789101112131415161718
  1. #!/bin/sh
  2. trap cleanup 0 1 2 3 6 15
  3. cleanup()
  4. {
  5. echo Terminating $SERVICENAME
  6. docker stop $(docker ps -q -f label=ru.sdsys.subcontainer=$SERVICENAME)
  7. docker rm -f $(docker ps -a -q -f label=ru.sdsys.subcontainer=$SERVICENAME)
  8. }
  9. SERVICENAME=$(docker inspect $HOSTNAME -f "{{index .Config.Labels \"com.docker.swarm.service.name\"}}")
  10. echo Starting $SERVICENAME
  11. exec "docker" "run" "-l" "ru.sdsys.subcontainer=$SERVICENAME" "$@" &
  12. wait