We can do this running our image interactively which creates a temporary container for:
docker run --rm -it \
--name my_container \
--volume $PWD:/some_dir_in_container \
--workdir /some_dir_in_container \
golang:1.13-buster bash
Description:
- $PWD above indicates your current working directory. You can change it with a custom path as well.
--rm
tells Docker to remove the container created after an exit.-it
combines--interactive
and--tty
options in order to keep stdin open even if not attached and allocate a pseudo-TTY.--volume
optional volume to bind with container.--workdir
optional way to set a working directory inside the container.
Additionally you can append other options like --user
in order to switch to a specific user. E.g --user myuser:mygroup
More details about options available refer to https://docs.docker.com/engine/reference/run/