Reputation: 341
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 run --name my-running-container my-image
How can i achieve this?
Thanks
Upvotes: 0
Views: 226
Reputation: 1213
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.
Upvotes: 1