Reputation: 103
I'm somewhat new to Docker. I would like to be able to use Docker to distribute a CLI program, but run the program normally once it has been installed. To be specific, after running docker build
on the system, I need to be able to simply run my-program
in the terminal, not docker run my-program
. How can I do this?
I tried something with a Makefile which runs docker build -t my-program .
and then writes a shell script to ~/.local/bin/
called my-program
that runs docker run my-program
, but this adds another container every time I run the script.
EDIT: I realize is the expected behavior of docker run
, but it does not work for my use-case.
Any help is greatly appreciated!
Upvotes: 0
Views: 478
Reputation: 936
If you want to keep your script, add the remove flag --rm
to the docker run
command. The remove flag removes the container automatically after the entry-point process has exit.
Additionally, I would personally prefer an alias
for this. Simply add something like this example alias my-program="docker run --rm my-program"
to your ~/.bashrc
or ~/.zshrc
file. This even has the advantage that all other parameters after the alias (my-program param1 param2
) are automatically forwarded to the entry-point of your image without any additional effort.
Upvotes: 2