your daily cup of tea™

powered by

A docker compose command that brings up a service without a command

Here is a fun one I got whilst trying to justify why abusing docker compose accepting file inputs from stdin is a very powerful pattern

# Bring up services without a command
#
# usage:
# nocmd.sh up -d service_name

function _compose {
  docker-compose -f docker-compose.yml $@
}

function nocmd {
  cat << EOF
  services:
    $1:
      command: tail -f /dev/null
EOF
}

function nocmd_compose {
  local service=${@: -1}
  _compose -f <(nocmd "$service") $@
}

nocmd_compose $@

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.