Last active
January 3, 2020 20:27
-
-
Save nclv/84e3a1d082209d33a0dded750385d09c to your computer and use it in GitHub Desktop.
docker aliases from https://blog.ropnop.com/docker-for-pentesters/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias dockershell="docker run --rm -i -t --entrypoint=/bin/bash" | |
alias dockershellsh="docker run --rm -i -t --entrypoint=/bin/sh" | |
function dockershellhere() { | |
dirname=${PWD##_/} | |
docker run --rm -it --entrypoint=/bin/bash -v `pwd`:/${dirname} -w /${dirname} "$@" | |
} | |
function dockershellshhere() { | |
dirname=${PWD##_/} | |
docker run --rm -it --entrypoint=/bin/sh -v `pwd`:/${dirname} -w /${dirname} "$@" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What do these do? They simply let me specify an image and drop into an interactive shell in a fresh, disposable environment. I can look around, make changes, test things, and then when I’m finished and type “exit”, everything is destroyed and cleaned up.
dockershell executes /bin/bash, while dockershellsh executes /bin/sh. This is useful since not every Docker image has bash installed.
The ones that end in here take it one step further and mount my current working directory inside the disposable container. This lets me interact with my files inside the disposable environment, and anything I write to that directory while inside the container persists after exit.
For example :
No spinning up a VM, no SSH, just instant shell access to test something out. And when I’m done it’s destroyed and the next time I run it I have a fresh instance again.