Skip to content

Instantly share code, notes, and snippets.

@rayjohnson
Created August 4, 2016 16:12
Show Gist options
  • Save rayjohnson/dfcaab1bfbd111ecbb6d2a5fd486fee0 to your computer and use it in GitHub Desktop.
Save rayjohnson/dfcaab1bfbd111ecbb6d2a5fd486fee0 to your computer and use it in GitHub Desktop.
Docker 1.12 create service --mount option
I was trying to install cadvisor using the new docker service option. Paticularly using the new --mode global option which is perfect for something like that.
However, I quickly ran into a problem because -v is not supported. What? There is a new --mount option - but I could find no documentation on it.
Now there is a bug to fix the docs: https://github.com/docker/docker/issues/24277
In the mean time I dug around and found that the format for that call would be something like this:
--mount type=volume,target=<container file/directory>,source=<host file/directory>,volume-driver=<driver>,volume-opts=<k0>=<v0>,volume-opts=<k1>=<v1>
So now I have this command to launch cadvisor on every machine:
docker service create --name cadvisor --mode global --publish=8080:8080 --mount=type=volume,source=/,target=/rootfs:ro --mount=type=volume,source=/var/run,target=/var/run:rw --mount=type=volume,source=/sys,target=/sys:ro --mount=type=volume,source=/var/lib/docker/,target=/var/lib/docker:ro google/cadvisor:latest
Enjoy!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment