diff options
author | Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org> | 2017-08-09 14:00:49 +0000 |
---|---|---|
committer | Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org> | 2017-08-09 14:15:22 +0000 |
commit | 11209581269419b84a1984df773892df9d30c1ab (patch) | |
tree | ba57e2c243c85aa02297f875294eb0c6fcad501c /start-container-docker.sh | |
parent | d4253a9f60688233bf9e2909c73c4f68cdd8b5fe (diff) |
start-container-docker.sh: Add customization necessary for QEMU VMs.
Running QEMU VMs requires container to run in privileged mode (KVM
needs this; non-KVM VMs can do without it). For this we pass
--docker_opts "--privileged".
When running QEMU VM we forward port 2222 of container to port of
the VM. Consequently, we need to publish port 2222 to outside of
container (on a random port). For this we pass --docker_opts "-p 2222".
Finally, we add ${prefix}container_id to the exported interface.
We require this to resolve external port mapped to VM's port 22.
Change-Id: I3d5d58ec4de02b82acd4ed097892651a656edaf5
Diffstat (limited to 'start-container-docker.sh')
-rwxr-xr-x | start-container-docker.sh | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/start-container-docker.sh b/start-container-docker.sh index 66f5c26b..fc7503df 100755 --- a/start-container-docker.sh +++ b/start-container-docker.sh @@ -15,7 +15,7 @@ set -e # - definition of ${session_host} and ${session_port}, can be used for # a remote connexion to the container usage() { - echo "Usage: $0 [--arch container-arch] --distro flavour [--label label] [--node node] [--prefix prefix] [--session-host host] [--session-name name] [--task {build|test}] [--weight weight]" + echo "Usage: $0 [--arch container-arch] --distro flavour [--docker_opts opts] [--label label] [--node node] [--prefix prefix] [--session-host host] [--session-name name] [--task {build|test}] [--weight weight]" echo echo " container-arch: architecture (eg: amd64, i386, arm64, armhf)" echo " distro: distribution (eg: trusty)" @@ -38,6 +38,7 @@ exec 1>&2 container_arch= distro= +docker_opts= label= node= prefix= @@ -59,6 +60,11 @@ do [ x${distro} = x ] && usage shift 2 ;; + --docker_opts) + docker_opts="$2" + [ x${docker_opts} = x ] && usage + shift 2 + ;; --label) label=$2 [ x${label} = x ] && usage @@ -194,6 +200,7 @@ session_id=$($DOCKER run --name $session_name -dtP \ --memory=${memory}M \ --pids-limit=${pids} \ --cpu-shares=${cpus} \ + ${docker_opts} \ $image) set +x @@ -251,8 +258,10 @@ ${prefix}container_exec () { remote_exec "${session_host}:${session_port}:\$(pwd)" "\$@" } + ${prefix}container_host=${session_host} ${prefix}container_port=${session_port} +${prefix}container_id=${session_id} container_prefix_list+=("${prefix}") |