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:

  • Docker-Compose Postgresql import dump
  • x509: certificate signed by unknown authority - both with docker and with github
  • Docker with GUI application
  • How to set the DOCKER_HOST env variable on a MAC
  • Using maven-failsafe with fabric8-maven to run integration tests that hit a containerised DB
  • Docker version 1.13.1, Docker Swarm, jwilder/nginx-proxy will not start as a docker service
  • docker run --name my-running-container my-image

    How can i achieve this?


  • How to run nginx with docker container?
  • Docker compose install requirements in a shared directory
  • Docker, web app static files. Best practices?
  • Docker Compose - container receiving connection refused
  • How to publish/push Dockerfile?
  • Docker Django 404 for web static files, but fine for admin static files
  • 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.