wishlist: package cli as a docker container
Opened this issue · 4 comments
For easier usage, it would be interesting to package the tool as a docker container, and avoiding the need of locally installing the extra package dependencies.
Mockup invocation
docker run monroe/cli create my/experiment --new --ssh
This makes extra sense since experimenters are already using docker to create the experiment containers, the monroe/base image is therefore already downloaded, etc.
I'll see if I go about it myself, but for now I'm just adding it to the wishlist issues.
It should be straightforward, but we need to figure out the mapping of ~/.monroe directory and the cert setup.
Hi, I've had a go at this, see the new Docker folder. You supply it your iMinds certificate and your import password prior to building it (see files/README.md), it automatically converts it to the right format and puts it in the right folder. An rsa key is also generated as part of the container build for ssh-ing into Monroe nodes. After building it, things work as your expect:
$ docker run monroe-docker whoami
Authentication ID: 169, Name: Ana Custura, Storage Quota remaining: 94765508608 bytes
$docker run -it monroe-docker create monroe/base --ssh
..correctly allows you to ssh into a test node and interact with it.
You can download results too by mapping to directory /root/results.
$ docker run -v /your/local/directory/:/root/results/ monroe-docker results <experiment-id>
The alternative option is to extract the cert and key yourself + create an ssh key into a ./monore/ directory and simply map this to the container, but that needs some changes to the Dockerfile supplied.
Anyway, let me know if this works for you.
Hi,
I have created a alternative approach that do not require you to build the certs into the docker container but instead uses a wrapper script.
The container can be found here: https://hub.docker.com/r/jonakarl/monroe-cli/
The wrapper script (monroe.sh) is this :
#!/bin/bash
CONTAINER=jonakarl/monroe-cli
DATA_CONTAINER=monroe-cli-data
COMMAND=$1
if [ "${COMMAND}" == "setup" ]
then
cert_path=$2
results_dir=$3
if [[ "${results_dir}" == "" || "${cert_path}" == "" ]]
then
echo "usage : monroe.sh setup <cert_path> <results_path>"
exit 1
fi
docker rm ${DATA_CONTAINER} >& /dev/null
docker create -v ${results_dir}:/results --name ${DATA_CONTAINER} ${CONTAINER} >& /dev/null
docker run -it --volumes-from=${DATA_CONTAINER} -v ${cert_path}:/cert.p12 ${CONTAINER} setup /cert.p12
else
results_dir=$(docker inspect ${DATA_CONTAINER} 2> /dev/null |jq -r '.[].Mounts[] | select(.Destination=="/results") | .Source')
if [ "${results_dir}" == "" ]
then
echo "Need to first run monroe.sh setup <cert_path> <results_path>"
exit 1
fi
if [ "${COMMAND}" == "results" ]
then
echo "Results mounted on : ${results_dir}"
fi
docker run -it --volumes-from=${DATA_CONTAINER} ${CONTAINER} $*
fi
I cannot do any PR but I have attached a patch to the commit : b40ac36
altdockerpatch.txt
-edit: fixed formatting