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 dockerize web application that will be customized?
  • docker run command output
  • “meteor run --production” with MONGO_URL vs. bundling
  • Get mysql error when deploy laravel project with Docker
  • Docker IPv6: Disable IPv4 in bridge docker0 and docker network
  • Executing Symfony Composer Update in Docker-Compose Results in Cache Error
  • docker run --name my-running-container my-image
    

    How can i achieve this?

    Thanks

  • Enabling debug on Wildfly domain mode in Docker - port already in use
  • Packer docker build exits code 137 when running runit cookbook
  • Returning value outside of function
  • Run two docker compose with same static ip on a host
  • Development env NodeJS and Docker
  • Docker volume command line option mistaking files for directories
  • 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:

    #!/bin/bash
    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.