MDL development image including docker in docker
This image has the necessary tools to build, test, edit, lint and version the MDL source code. It comes with the Vim editor installed, along with some plugins to ease go development and version control with git, besides it comes with docker installed.
$ mkdir src
$ docker run --privileged --rm \
-v src:/go/src MDLlife/MDLdev-cli:dind \
go get github.com/MDLlife/MDL
$ sudo chown -R `whoami` src
This downloads the mdl source to src/MDLlife/MDL and changes the owner to your user. This is necessary, because all processes inside the container run as root and the files created by it are therefore owned by root.
If you already have a Go development environment installed, you just need to mount the src directory from your $GOPATH in the /go/src volume of the container.
You can run commands by just passing them to the image. Everything is run in a container and deleted when finished.
$ docker run --rm \
-v src:/go/src MDLlife/MDLdev-cli:dind \
sh -c "cd mdl; make test"
$ docker run --rm \
-v src:/go/src MDLlife/MDLdev-cli:dind \
sh -c "cd mdl; make lint"
$ docker run --rm \
-v src:/go/src MDLlife/MDLdev-cli:dind \
vim
$ docker run --privileged --name some-name -d MDLlife/MDLdev-cli:dind
Create a data directory on the host system (outside the container) and mount this to a directory visible from inside the container.
The downside is that you need to make sure that the directory exists, and that e.g. directory permissions and other security mechanisms on the host system are set up correctly.
- Create a data directory on a suitable volume on your host system, e.g. /my/own/var-lib-docker.
- Start your docker container like this:
$ docker run --privileged --name some-name -v /my/own/var-lib-docker:/var/lib/docker \
-d MDLlife/MDLdev-cli:dind