Skip to content

Commit

Permalink
Merge pull request #66 from sandrokeil/feature/own-container-name
Browse files Browse the repository at this point in the history
--name: Add support for own Docker container name (close #61)
  • Loading branch information
mviereck authored Jul 18, 2018
2 parents a9e0ff8 + 10d456b commit 6e7affb
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions x11docker
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,7 @@ cleanup() { # --cleanup : check for non-removed containers and left
grep -q .cache/x11docker <<<$Cachebasefolder && Orphanedfolders=$(find "$Cachebasefolder" -mindepth 1 -maxdepth 1 -type d | sed s%$Cachebasefolder/%% | grep -v x11docker-gui)
[ "${X11DOCKER_LASTCLEANFOLDER:-}" ] && Orphanedfolders="$(echo "$Orphanedfolders" | grep -v $X11DOCKER_LASTCLEANFOLDER)"
Orphanedcontainers="$(docker ps -a --filter name=x11docker_X --format "{{.Names}}")"
Orphanedcontainers="$Orphanedcontainers $(find "$Cachebasefolder" -mindepth 2 -maxdepth 2 -type f -name 'container.id' -exec cat {} \;)"
Orphanedcontainers="$(env IFS='' echo $Orphanedcontainers)"

[ -z "$Orphanedcontainers$Orphanedfolders" ] && {
Expand Down Expand Up @@ -1527,7 +1528,7 @@ stdout() {
Longoptions="$Longoptions,starter,cleanup,license,licence,help,version,install,update,update-master,remove,wmlist" # special options without starting X server
Longoptions="$Longoptions,xhost:,no-auth,vt:,display:,xtest,no-xtest,env:,showenv,showid,showpid1" # X and environment options
Longoptions="$Longoptions,verbose,silent,debug,stdout,stderr,stdin" # verbose options
Longoptions="$Longoptions,hostipc,hostnet,ps,cache,cap-default,no-entrypoint,sudouser,hostuser:,group-add:" # capabilities, users
Longoptions="$Longoptions,hostipc,hostnet,ps,cache,cap-default,no-entrypoint,sudouser,hostuser:,group-add:,name:" # capabilities, users
Longoptions="$Longoptions,cachedir:,homedir:,westonini:,sharedir:,keymap:,runfromhost:,runasroot:,sharessh" # developer options

Parsedoptions="$(getopt --options $Shortoptions --longoptions $Longoptions --name "$0" -- "$@" 2>/tmp/x11docker_parsererror)"
Expand Down Expand Up @@ -1674,6 +1675,7 @@ $Customenvironment" ; shift ;; # set custom environm
--hostipc) Sharehostipc="yes" ;; # docker run option --ipc=host
--hostnet) Sharehostnet="yes" ;; # docker run option --net=host
--cap-default) Capdropall="no" ;; # don't use --cap-drop=ALL
--name) Containername="${2:-}" ; shift ;; # set container name

## miscellaneous
--ps) Preservecachefiles="yes" ;; # preserve container instead of removing it with 'docker run --rm'
Expand Down Expand Up @@ -4187,7 +4189,7 @@ DefaultEnvironment=DISPLAY=$Newdisplay XAUTHORITY=$Cshare/Xclientcookie $(IFS=$'
run) Dockercommand="docker run -d --tty"
[ "$Preservecachefiles" = "no" ] && Dockercommand="$Dockercommand --rm"
Containername="x11docker_X${Newdisplaynumber}_${Mycookie}_$Imagenametr"
[ -z "$Containername" ] && Containername="x11docker_X${Newdisplaynumber}_${Mycookie}_$Imagenametr"
Dockercommand="$Dockercommand --name=$Containername"
verbose "Container name: $Containername"
Expand Down

0 comments on commit 6e7affb

Please sign in to comment.