• This repository has been archived on 08/Jan/2018
  • Stars
    star
    371
  • Rank 115,103 (Top 3 %)
  • Language
    Go
  • Created about 10 years ago
  • Updated over 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Docker Volume Manager

Docker Volume Manager

WARNING

Docker 1.7 introduced some changes that broke functionality in this project. Docker 1.8 introcuded yet more changes that broke functionality here. This has always been intended as a way to prototype this functionality for Docker itself. Being that native docker volumes support is planned for Docker 1.9 and the maintainence burden this project brings, I am no longer going to maintain this. I will happily accept pull requests to fix issues, but will not provide any new fixes. Sorry for the inconveniece, and thank you for helping out with this project!


This is a tool for managing your Docker volumes.

Basically, since volumes are not yet first-class citizens in Docker they can be difficult to manage. Most people tend to have extra volumes laying around which are not in use because they didn't get removed with the container they were used with.

You can run this tool remotely just as you do with the Docker CLI. It reads DOCKER_HOST or you can specify a host using the same syntax as with Docker, with -H unix:///path/to/sock.sock or --host unix:///path/to/sock.sock. This also works with TCP endpoints

Use this to see all your volumes, inspect them, export them, or clean them up.

The primary goal of this project is to spec out UI/API for inclusion in Docker. Some of the implementation is hacky since I specifically wanted the CLI for this to act just like the Docker CLI, that is that it doesn't need to be running on the host or have access to the host's filesystem for it to work.

Caveats

The export function is horribly inefficient, for a couple of reasons:

  1. The tools is inteded to be used remotely, so there is no direct access to the host FS, and as such the volumes or container filesystems.

  2. The docker cp command, and the corresponding APIs, do not support volumes. For instance you cannot do docker cp jolly_torvalds:/path/to/volume like you can for things not in volumes. Well, you can, but it won't be the data in the volume... it will be the data at that location from the container's FS

To work around these issues the export function actually copies data from a volume into a container's FS, then uses the docker cp APIs to pull it.

Installation

You can download a pre-built binary from the releases section. Or you can use the docker image as such:

docker run -v /var/run/docker.sock:/var/run/docker.sock cpuguy83/docker-volumes list

Building

You can use the provided Dockerfile.build which will compile a binary for you or build yourself.

git clone https://github.com/cpuguy83/docker-volumes.git
cd docker-volumes
docker build -t docker-volumes -f Dockerfile.build .
docker run --name docker-volumes docker-volumes
docker cp docker-volumes:/docker-volumes ./

By default when compiling from the Dockerfile it will compile for linux/amd64. You can customize this using environment variables as such:

docker run --name docker-volumes -e GOOS=darwin -e GOARCH=amd64 docker-volumes

This would make a binary for darwin/amd64 (OSX), available for docker cp at the same location as above.

Alternatively, if you already have golang installed on your system you can compile it yourself:

git clone https://github.com/cpuguy83/docker-volumes.git
cd docker-volumes
go get
go build

Usage

Commands:

  • list - Lists all volumes on the host
  • inspect - Get details of a volume, takes ID or name from output of list
  • rm - Removes a volume. A volume is only removed if no containers are using it
  • export - Creates an archive of the volume and outputs it to stdout. You can optionally pause all running containers (which are using the requested volume) before exporting the volume using --pause
  • import - Import a tarball generated by the export command from stdin to a specified container. Be default it will import it into the same directory path the volume existed on (eg, if it came from /data, it will put it into /data) You can optionally specify a different volume path, but a volume must exist at that path already or you will get an error
NAME:
   docker-volumes - The missing volume manager for Docker

USAGE:
   docker-volumes [global options] command [command options] [arguments...]

VERSION:
   1.0.0

AUTHOR:
  Brian Goff - <[email protected]>

COMMANDS:
   list		List all volumes
   inspect	Get details of volume
   rm		Delete a volume
   export	Export a as a tarball. Prints to stdout
   import	Import a tarball produced by the export command the specified container
   help, h	Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --host, -H '/var/run/docker.sock'	Location of the Docker socket [$DOCKER_HOST]
   --help, -h				show help
   --version, -v			print the version

Examples

docker-volumes list

+--------------+-----------------------------+---------------------------------------------------------------------------------------------------+
  f2247e6839b1 | romantic_thompson:/data     | /mnt/sda1/var/lib/docker/vfs/dir/f2247e6839b1ea7ded4123bdc2790e184e6ab6ee3b614fbcb1a72e7bad40e90c
  452484414b40 | romantic_thompson:/moreData | /mnt/sda1/var/lib/docker/vfs/dir/452484414b407c7823357b2cac6812d4e0aa47ca13bd91c68fbe8626760e1adb
  d40880431eb5 | focused_brattain:/data      | /mnt/sda1/var/lib/docker/vfs/dir/d40880431eb5f49a36bba5f5dd5500ae5fc85f9d8d8e4253a7b434302750dead
  f92b748ca057 | insane_feynman:/data        | /mnt/sda1/var/lib/docker/vfs/dir/f92b748ca05768688b41703c2b011520cba7dc2a58acdf10007a83e6c17c5084

# exports volume at /data and sends into ./foo.tar
docker-volumes export insane_feynman:/data > foo.tar

# export and also pause each container using that volume, unpauses when export is finished
docker-volumes export --pause insane_feynman:/data > foo.tar

# pipe in foo.tar and import to the insane_feynman container at the same /data path
cat foo.tar | docker-volumes import insane_feynman

# pipe in foo.tar and import to the romantic_thompson container at the /moreData path
cat foo.tar | docker-volumes import romantic_thompson /moreData

# export from focussed_brattain and pipe directly into the import for insane_feynman
docker-volumes export focused_brattain:/data | docker-volumes import insane_feynman

# export focussed_brattain and pipe into jolly_torvalds at a remote docker instance
docker-volumes export focused_brattain:/data | docker-volumes -H tcp://1.2.3.4:2375 jolly_torvalds

More Repositories

1

go-md2man

Go
230
star
2

docker-grand-ambassador

Go
194
star
3

docker-nfs-server

Shell
151
star
4

dockerhub-webhook-listener

Listens for dockerhub webhook calls
Go
84
star
5

kvfs

FUSE based filesystem for KV stores
Go
60
star
6

containerd-shim-systemd-v1

Go
57
star
7

docker-nagios

Shell
52
star
8

docker-log-driver-test

Go
50
star
9

docker-openvpn

Shell
34
star
10

drax

An embeddable distributed k/v store for Go
Go
33
star
11

docker-nfs-client

Shell
32
star
12

gonso

Library to work with linux namespaces in go
Go
32
star
13

docker-rails-dev-demo

Ruby
26
star
14

zapp

Tool to interact with Docker registry objects.
Go
24
star
15

docker-mail

Postfix+Dovecot in Docker
Shell
21
star
16

docker-compose-reloader

Monitor fs events and reload docker-compose on changes
Go
19
star
17

go-docker

Experimental Docker client
Go
19
star
18

docker-ipsec

Shell
17
star
19

dockercfg

Library to load docker CLI configs, auths, etc w/ minimal deps
Go
16
star
20

tarfs

A fuse-based filesystem for accessing tar files
Go
13
star
21

strongerrors

A simple package for defining common error classes
Go
12
star
22

go-grpc-pprof

A GRPC service for interacting with pprof
Go
12
star
23

docker-kvfs-driver

Docker Volume Driver for distributed k/v stores
Go
11
star
24

pack_rat

Rails cache helper method
Ruby
11
star
25

mongoid_connection_pool

Adds connection pooling for mongoid
Ruby
10
star
26

docker-debian

Shell
9
star
27

docker-onbuild_demo

Demo for Docker 0.8's new ONBUILD builder instruction
Ruby
9
star
28

docker-who

Go
8
star
29

otrs_connector

Connect your rails app to OTRS/ITSM
Ruby
7
star
30

qemu-micro-env

Go
6
star
31

docker-backup

Ruby
6
star
32

dockerclient

Go
5
star
33

cri-containerd-flame

Generate flamegraphs from cri-containerd using bucketbench to drive workloads
Makefile
5
star
34

rails_otrs

A rails 3 app to bridge the OTRS JSON API to rails in a RESTful way that feels like ActiveRecord
Ruby
4
star
35

tar2go

Go
4
star
36

docker-metrics-plugin-test

Go
4
star
37

docker-postgres

Shell
3
star
38

docker-hub-buildtag

Go
2
star
39

ocipush

Go
2
star
40

docker-torch

Go
2
star
41

go-vsock

Go
2
star
42

pj_link

A simple library for communicating over the PJLink protocol
Ruby
2
star
43

docker-ntpdate

Shell
2
star
44

ruby-goroutine

Ruby
2
star
45

execctx

Wrap Go's os/exec with custom context handling
Go
2
star
46

blog

CSS
2
star
47

docker-ruby-app

Build Docker containers for ruby apps
Shell
2
star
48

docker-testing

Setup integration tests for docker engine/cli with github actions
Shell
2
star
49

docker-mongodb

Shell
2
star
50

docker-ldap

Shell
1
star
51

docker-ruby-buildpack

Ruby
1
star
52

docker-hipache

Shell
1
star
53

fakenode

1
star
54

docker-logdriver-discard

A docker log driver that discards all messages -- for testing purposes only
Go
1
star
55

multiio

Go package for treating multiple IO streams as one
Go
1
star
56

chef-openldap-server

OpenLDAP Server Cookbook for Chef
Ruby
1
star
57

docker-rbx

Docker Rubinius build
1
star
58

registrar

library for name registration
Go
1
star
59

idmapfs

fuse filesystem which maps filesystem access based on uid/gid maps
Go
1
star
60

docker-megaraid_status

Check status of MegaRAID controller
Shell
1
star
61

k8s-containerd-runtime-installer

Go
1
star
62

docker-etcd

1
star
63

pipes

Go
1
star
64

docker-btsync

Shell
1
star
65

go-generate

Go
1
star
66

containerd-api

Fork of containerd/containerd to extract out api and reduce deps
Go
1
star
67

memlogd-docker

Docker logdriver for linuxkit/memlogd
Go
1
star
68

rbx_sidekiq_crash_test_example

Example App to demonstrate Sidekiq crashing on Rubinus
Ruby
1
star
69

docker112rc3-runtimefix

Go
1
star
70

go-mail

Go
1
star
71

faye-client

Ruby
1
star