Bash Command Templating For Docker

I have a commonly typed and now tedious command to start and link a docker container. It’s something like:

docker run -d --name my-running-container --link app:some-app-command --link rabbitmq:amq --link mysql:db --link neo4j:neo --link solr:solr my-image

I would prefer to just execute:

  • How to create a shared volume between docker host and container in Mac
  • Docker Compose Overriding
  • Best strategy for automatize a flow that need user interaction
  • Mounting a directory located on an alternate host computer volume. Possible? (Docker)
  • How to connect mysql in a rails appliation with docker?
  • Configure PM2 module with linked docker container
  • docker run --name my-running-container my-image

    How can i achieve this?


  • How to handle specific hostname like -h option in Dockerfile
  • How to Keep Docker Container Running After Starting Services?
  • How to configure the publish address of elasticsearch 5.0 with CLI flags?
  • Dependent Containers and Links with IBM DevOps Services Build Pipeline
  • block device access on windows docker tool box
  • Restart docker with different environment variable
  • One Solution collect form web for “Bash Command Templating For Docker”

    You can create a simple bash script named docker or whatever name you like:

    DOCKER=`which docker`
    $DOCKER run -d --name $1 --link rabbitmq:amq --link mysql:db --link neo4j:neo --link solr:solr $2

    and then run it like ./docker my-running-container my-image

    The same thing could be achieved with bash alias:

    alias docker='docker run -d --name $1 --link rabbitmq:amq --link mysql:db --link neo4j:neo --link solr:solr $2'

    If you want to save the alias just add it at the end of ~/.bash_aliases and reload your shell.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.