EMBARK_DOCKER_RUN_RM

This commit is contained in:
Michael Bradley, Jr 2018-08-02 14:08:22 -05:00
parent 87abc0bfe0
commit eaf05016fb
2 changed files with 21 additions and 2 deletions

View File

@ -37,9 +37,9 @@ docker build \
$EMBARK_DOCKERFILE $EMBARK_DOCKERFILE
source <(curl $RUNNER) source <(curl $RUNNER)
run_embark --rm -- demo run_embark demo
cd embark_demo cd embark_demo
run_embark --rm -- run_embark
``` ```
Review the Review the
@ -62,6 +62,20 @@ EMBARK_DOCKER_RUN_OPTS_REPLACE=true
run_embark [docker-run-opts] -- [command] run_embark [docker-run-opts] -- [command]
``` ```
By default `run.sh` invokes `docker run` with the
[`--rm`](https://docs.docker.com/engine/reference/run/#clean-up---rm) option,
making the embark container ephemeral, i.e. it will not persist on the docker
host's file system after the container exits. To override this behavior:
``` shell
EMBARK_DOCKER_RUN_RM=false
run_embark [docker-run-opts] -- [command]
```
Note that if you have `EMBARK_DOCKER_RUN_OPTS_REPLACE=true`, then `--rm` would
need to be provided in `[docker-run-opts]`, i.e. `EMBARK_DOCKER_RUN_RM` will be
effectively ignored.
### Shortcuts ### Shortcuts
These are equivlent: These are equivlent:

5
run.sh
View File

@ -7,6 +7,7 @@ run_embark () {
local EMBARK_DOCKER_RUN="${EMBARK_DOCKER_RUN}" local EMBARK_DOCKER_RUN="${EMBARK_DOCKER_RUN}"
local EMBARK_DOCKER_RUN_INTERACTIVE=${EMBARK_DOCKER_RUN_INTERACTIVE:-false} local EMBARK_DOCKER_RUN_INTERACTIVE=${EMBARK_DOCKER_RUN_INTERACTIVE:-false}
local EMBARK_DOCKER_RUN_OPTS_REPLACE=${EMBARK_DOCKER_RUN_OPTS_REPLACE:-false} local EMBARK_DOCKER_RUN_OPTS_REPLACE=${EMBARK_DOCKER_RUN_OPTS_REPLACE:-false}
local EMBARK_DOCKER_RUN_RM=${EMBARK_DOCKER_RUN_RM:-true}
local EMBARK_DOCKER_TAG="${EMBARK_DOCKER_TAG:-latest}" local EMBARK_DOCKER_TAG="${EMBARK_DOCKER_TAG:-latest}"
local -a run_opts=( local -a run_opts=(
@ -38,6 +39,10 @@ run_embark () {
"TERM" "TERM"
) )
if [[ $EMBARK_DOCKER_RUN_RM = true ]]; then
run_opts=( "${run_opts[@]}" "--rm" )
fi
local txtbld=$(tput bold) local txtbld=$(tput bold)
local txtrst=$(tput sgr0) local txtrst=$(tput sgr0)