If you want to be to quickly install something, or try something out, but not pollute your environment, then docker is a great way to do that. Here is a one line command that will start new docker bash terminal (and mount the current working directory inside the docker container):

docker run -v $(pwd):/opt -w="/opt" --rm -it debian:latest bash

Add this to your .bashrc file as an alias so it can be run very quickly any time:

alias dock='docker run -v $(pwd):/opt -w="/opt" --rm -it debian:latest bash'

Customizing Your Container bash:

If you are often running this, then you might might find it handy to have your own custom .bashrc file mounted inside the container, so that all your aliases, and other settings are available by default. You can do this by simply mounting your .bashrc file.

-v $(echo ~)/.config/.docker_bash:/root/.bashrc

Naturally “/.config/.docker_bash” would be the path to your file .bashrc file that you want to use inside the container.

So the full command that I use myself:

alias dock='docker run -v $(pwd):/opt -w="/opt" --rm -v $(echo ~)/.config/.docker_bash:/root/.bashrc -it debian:latest bash'

Leave a Reply

Your email address will not be published. Required fields are marked *