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:

  • scrapy-cluster : socket.error: [Errno 98] Address already in use
  • nginx reverse proxy with docker - load balancing
  • Docker for non-code deployments?
  • Correct way to access url/api endpoints of other docker containers in the same docker network?
  • Saving function output into a variable named in an argument
  • Clear all entries in Docker mongodb?
  • docker run --name my-running-container my-image

    How can i achieve this?


  • How to remove docker images based on name?
  • Docker : find sendmail in other container
  • External properties file using Spring Boot and Docker
  • Docker - misunderstanding about the execution and volume
  • Docker Containers on Marathon disappeared
  • trapping signal from “docker stop” in bash
  • 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.