зеркало из https://github.com/microsoft/docker.git
Add option to specify name without --name in volume create
Signed-off-by: Kara Alexandra <kalexandra@us.ibm.com>
This commit is contained in:
Родитель
8d99dfbc69
Коммит
ba3f0bf0e7
|
@ -26,17 +26,25 @@ func newCreateCommand(dockerCli *client.DockerCli) *cobra.Command {
|
|||
}
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: "create [OPTIONS]",
|
||||
Use: "create [OPTIONS] [VOLUME]",
|
||||
Short: "Create a volume",
|
||||
Long: createDescription,
|
||||
Args: cli.NoArgs,
|
||||
Args: cli.RequiresMaxArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
if len(args) == 1 {
|
||||
if opts.name != "" {
|
||||
fmt.Fprint(dockerCli.Err(), "Conflicting options: either specify --name or provide positional arg, not both\n")
|
||||
return cli.StatusError{StatusCode: 1}
|
||||
}
|
||||
opts.name = args[0]
|
||||
}
|
||||
return runCreate(dockerCli, opts)
|
||||
},
|
||||
}
|
||||
flags := cmd.Flags()
|
||||
flags.StringVarP(&opts.driver, "driver", "d", "local", "Specify volume driver name")
|
||||
flags.StringVar(&opts.name, "name", "", "Specify volume name")
|
||||
flags.Lookup("name").Hidden = true
|
||||
flags.VarP(&opts.driverOpts, "opt", "o", "Set driver specific options")
|
||||
flags.StringSliceVar(&opts.labels, "label", []string{}, "Set metadata for a volume")
|
||||
|
||||
|
@ -67,7 +75,7 @@ Creates a new volume that containers can consume and store data in. If a name
|
|||
is not specified, Docker generates a random name. You create a volume and then
|
||||
configure the container to use it, for example:
|
||||
|
||||
$ docker volume create --name hello
|
||||
$ docker volume create hello
|
||||
hello
|
||||
$ docker run -d -v hello:/world busybox ls /world
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ parent = "smn_cli"
|
|||
# volume create
|
||||
|
||||
```markdown
|
||||
Usage: docker volume create [OPTIONS]
|
||||
Usage: docker volume create [OPTIONS] [VOLUME]
|
||||
|
||||
Create a volume
|
||||
|
||||
|
@ -19,14 +19,13 @@ Options:
|
|||
-d, --driver string Specify volume driver name (default "local")
|
||||
--help Print usage
|
||||
--label value Set metadata for a volume (default [])
|
||||
--name string Specify volume name
|
||||
-o, --opt value Set driver specific options (default map[])
|
||||
```
|
||||
|
||||
Creates a new volume that containers can consume and store data in. If a name is not specified, Docker generates a random name. You create a volume and then configure the container to use it, for example:
|
||||
|
||||
```bash
|
||||
$ docker volume create --name hello
|
||||
$ docker volume create hello
|
||||
hello
|
||||
|
||||
$ docker run -d -v hello:/world busybox ls /world
|
||||
|
@ -62,19 +61,19 @@ The built-in `local` driver on Linux accepts options similar to the linux `mount
|
|||
For example, the following creates a `tmpfs` volume called `foo` with a size of 100 megabyte and `uid` of 1000.
|
||||
|
||||
```bash
|
||||
$ docker volume create --driver local --opt type=tmpfs --opt device=tmpfs --opt o=size=100m,uid=1000 --name foo
|
||||
$ docker volume create --driver local --opt type=tmpfs --opt device=tmpfs --opt o=size=100m,uid=1000 foo
|
||||
```
|
||||
|
||||
Another example that uses `btrfs`:
|
||||
|
||||
```bash
|
||||
$ docker volume create --driver local --opt type=btrfs --opt device=/dev/sda2 --name foo
|
||||
$ docker volume create --driver local --opt type=btrfs --opt device=/dev/sda2 foo
|
||||
```
|
||||
|
||||
Another example that uses `nfs` to mount the `/path/to/dir` in `rw` mode from `192.168.1.1`:
|
||||
|
||||
```bash
|
||||
$ docker volume create --driver local --opt type=nfs --opt o=addr=192.168.1.1,rw --opt device=:/path/to/dir --name foo
|
||||
$ docker volume create --driver local --opt type=nfs --opt o=addr=192.168.1.1,rw --opt device=:/path/to/dir foo
|
||||
```
|
||||
|
||||
|
||||
|
|
|
@ -34,9 +34,9 @@ Lists all the volumes Docker knows about. You can filter using the `-f` or `--fi
|
|||
Example output:
|
||||
|
||||
```bash
|
||||
$ docker volume create --name rosemary
|
||||
$ docker volume create rosemary
|
||||
rosemary
|
||||
$docker volume create --name tyler
|
||||
$docker volume create tyler
|
||||
tyler
|
||||
$ docker volume ls
|
||||
DRIVER VOLUME NAME
|
||||
|
@ -91,9 +91,9 @@ a `label` and a value.
|
|||
First, let's create some volumes to illustrate this;
|
||||
|
||||
```bash
|
||||
$ docker volume create --name the-doctor --label is-timelord=yes
|
||||
$ docker volume create the-doctor --label is-timelord=yes
|
||||
the-doctor
|
||||
$ docker volume create --name daleks --label is-timelord=no
|
||||
$ docker volume create daleks --label is-timelord=no
|
||||
daleks
|
||||
```
|
||||
|
||||
|
|
|
@ -203,7 +203,7 @@ The following example also creates the `my-named-volume` volume, this time
|
|||
using the `docker volume create` command.
|
||||
|
||||
```bash
|
||||
$ docker volume create -d flocker --name my-named-volume -o size=20GB
|
||||
$ docker volume create -d flocker my-named-volume -o size=20GB
|
||||
|
||||
$ docker run -d -P \
|
||||
-v my-named-volume:/opt/webapp \
|
||||
|
|
|
@ -196,7 +196,7 @@ func (s *DockerDaemonSuite) TestVolumePlugin(c *check.C) {
|
|||
}
|
||||
}()
|
||||
|
||||
out, err = s.d.Cmd("volume", "create", "-d", pluginName, "--name", volName)
|
||||
out, err = s.d.Cmd("volume", "create", "-d", pluginName, volName)
|
||||
if err != nil {
|
||||
c.Fatalf("Could not create volume: %v %s", err, out)
|
||||
}
|
||||
|
|
|
@ -1827,7 +1827,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartRmVolumeInUse(c *check.C) {
|
|||
func (s *DockerDaemonSuite) TestDaemonRestartLocalVolumes(c *check.C) {
|
||||
c.Assert(s.d.Start(), check.IsNil)
|
||||
|
||||
_, err := s.d.Cmd("volume", "create", "--name", "test")
|
||||
_, err := s.d.Cmd("volume", "create", "test")
|
||||
c.Assert(err, check.IsNil)
|
||||
c.Assert(s.d.Restart(), check.IsNil)
|
||||
|
||||
|
|
|
@ -178,7 +178,7 @@ func (s *DockerSuite) TestVolumeEvents(c *check.C) {
|
|||
since := daemonUnixTime(c)
|
||||
|
||||
// Observe create/mount volume actions
|
||||
dockerCmd(c, "volume", "create", "--name", "test-event-volume-local")
|
||||
dockerCmd(c, "volume", "create", "test-event-volume-local")
|
||||
dockerCmd(c, "run", "--name", "test-volume-container", "--volume", "test-event-volume-local:/foo", "-d", "busybox", "true")
|
||||
waitRun("test-volume-container")
|
||||
|
||||
|
@ -355,7 +355,7 @@ func (s *DockerSuite) TestEventsFilterVolumeAndNetworkType(c *check.C) {
|
|||
since := daemonUnixTime(c)
|
||||
|
||||
dockerCmd(c, "network", "create", "test-event-network-type")
|
||||
dockerCmd(c, "volume", "create", "--name", "test-event-volume-type")
|
||||
dockerCmd(c, "volume", "create", "test-event-volume-type")
|
||||
|
||||
out, _ := dockerCmd(c, "events", "--filter", "type=volume", "--filter", "type=network", "--since", since, "--until", daemonUnixTime(c))
|
||||
events := strings.Split(strings.TrimSpace(out), "\n")
|
||||
|
@ -373,7 +373,7 @@ func (s *DockerSuite) TestEventsFilterVolumeID(c *check.C) {
|
|||
|
||||
since := daemonUnixTime(c)
|
||||
|
||||
dockerCmd(c, "volume", "create", "--name", "test-event-volume-id")
|
||||
dockerCmd(c, "volume", "create", "test-event-volume-id")
|
||||
out, _ := dockerCmd(c, "events", "--filter", "volume=test-event-volume-id", "--since", since, "--until", daemonUnixTime(c))
|
||||
events := strings.Split(strings.TrimSpace(out), "\n")
|
||||
c.Assert(events, checker.HasLen, 1)
|
||||
|
|
|
@ -409,7 +409,7 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverRetryNotImmediatelyE
|
|||
}
|
||||
|
||||
func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverBindExternalVolume(c *check.C) {
|
||||
dockerCmd(c, "volume", "create", "-d", "test-external-volume-driver", "--name", "foo")
|
||||
dockerCmd(c, "volume", "create", "-d", "test-external-volume-driver", "foo")
|
||||
dockerCmd(c, "run", "-d", "--name", "testing", "-v", "foo:/bar", "busybox", "top")
|
||||
|
||||
var mounts []struct {
|
||||
|
@ -424,7 +424,7 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverBindExternalVolume(c
|
|||
}
|
||||
|
||||
func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverList(c *check.C) {
|
||||
dockerCmd(c, "volume", "create", "-d", "test-external-volume-driver", "--name", "abc3")
|
||||
dockerCmd(c, "volume", "create", "-d", "test-external-volume-driver", "abc3")
|
||||
out, _ := dockerCmd(c, "volume", "ls")
|
||||
ls := strings.Split(strings.TrimSpace(out), "\n")
|
||||
c.Assert(len(ls), check.Equals, 2, check.Commentf("\n%s", out))
|
||||
|
@ -443,7 +443,7 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverGet(c *check.C) {
|
|||
c.Assert(s.ec.gets, check.Equals, 1)
|
||||
c.Assert(out, checker.Contains, "No such volume")
|
||||
|
||||
dockerCmd(c, "volume", "create", "--name", "test", "-d", "test-external-volume-driver")
|
||||
dockerCmd(c, "volume", "create", "test", "-d", "test-external-volume-driver")
|
||||
out, _ = dockerCmd(c, "volume", "inspect", "test")
|
||||
|
||||
type vol struct {
|
||||
|
@ -458,7 +458,7 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverGet(c *check.C) {
|
|||
}
|
||||
|
||||
func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverWithDaemonRestart(c *check.C) {
|
||||
dockerCmd(c, "volume", "create", "-d", "test-external-volume-driver", "--name", "abc1")
|
||||
dockerCmd(c, "volume", "create", "-d", "test-external-volume-driver", "abc1")
|
||||
err := s.d.Restart()
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
|
@ -474,7 +474,7 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverWithDaemonRestart(c
|
|||
func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverGetEmptyResponse(c *check.C) {
|
||||
c.Assert(s.d.Start(), checker.IsNil)
|
||||
|
||||
out, err := s.d.Cmd("volume", "create", "-d", "test-external-volume-driver", "--name", "abc2", "--opt", "ninja=1")
|
||||
out, err := s.d.Cmd("volume", "create", "-d", "test-external-volume-driver", "abc2", "--opt", "ninja=1")
|
||||
c.Assert(err, checker.IsNil, check.Commentf(out))
|
||||
|
||||
out, err = s.d.Cmd("volume", "inspect", "abc2")
|
||||
|
@ -487,7 +487,7 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverPathCalls(c *check.C
|
|||
c.Assert(s.d.Start(), checker.IsNil)
|
||||
c.Assert(s.ec.paths, checker.Equals, 0)
|
||||
|
||||
out, err := s.d.Cmd("volume", "create", "--name=test", "--driver=test-external-volume-driver")
|
||||
out, err := s.d.Cmd("volume", "create", "test", "--driver=test-external-volume-driver")
|
||||
c.Assert(err, checker.IsNil, check.Commentf(out))
|
||||
c.Assert(s.ec.paths, checker.Equals, 1)
|
||||
|
||||
|
@ -516,7 +516,7 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverCapabilities(c *chec
|
|||
c.Assert(s.ec.caps, checker.Equals, 0)
|
||||
|
||||
for i := 0; i < 3; i++ {
|
||||
out, err := s.d.Cmd("volume", "create", "-d", "test-external-volume-driver", "--name", fmt.Sprintf("test%d", i))
|
||||
out, err := s.d.Cmd("volume", "create", "-d", "test-external-volume-driver", fmt.Sprintf("test%d", i))
|
||||
c.Assert(err, checker.IsNil, check.Commentf(out))
|
||||
c.Assert(s.ec.caps, checker.Equals, 1)
|
||||
out, err = s.d.Cmd("volume", "inspect", "--format={{.Scope}}", fmt.Sprintf("test%d", i))
|
||||
|
|
|
@ -282,11 +282,12 @@ func testCommand(cmd string, newEnvs []string, scanForHome bool, home string) er
|
|||
|
||||
// These commands will never print a short-usage so don't test
|
||||
noShortUsage := map[string]string{
|
||||
"images": "",
|
||||
"login": "",
|
||||
"logout": "",
|
||||
"network": "",
|
||||
"stats": "",
|
||||
"images": "",
|
||||
"login": "",
|
||||
"logout": "",
|
||||
"network": "",
|
||||
"stats": "",
|
||||
"volume create": "",
|
||||
}
|
||||
|
||||
if _, ok := noShortUsage[cmd]; !ok {
|
||||
|
|
|
@ -704,7 +704,7 @@ func (s *DockerSuite) TestPsShowMounts(c *check.C) {
|
|||
|
||||
mp := prefix + slash + "test"
|
||||
|
||||
dockerCmd(c, "volume", "create", "--name", "ps-volume-test")
|
||||
dockerCmd(c, "volume", "create", "ps-volume-test")
|
||||
// volume mount containers
|
||||
runSleepingContainer(c, "--name=volume-test-1", "--volume", "ps-volume-test:"+mp)
|
||||
c.Assert(waitRun("volume-test-1"), checker.IsNil)
|
||||
|
|
|
@ -4307,7 +4307,7 @@ func (s *DockerSuite) TestRunNamedVolumeCopyImageData(c *check.C) {
|
|||
func (s *DockerSuite) TestRunNamedVolumeNotRemoved(c *check.C) {
|
||||
prefix, _ := getPrefixAndSlashFromDaemonPlatform()
|
||||
|
||||
dockerCmd(c, "volume", "create", "--name", "test")
|
||||
dockerCmd(c, "volume", "create", "test")
|
||||
|
||||
dockerCmd(c, "run", "--rm", "-v", "test:"+prefix+"/foo", "-v", prefix+"/bar", "busybox", "true")
|
||||
dockerCmd(c, "volume", "inspect", "test")
|
||||
|
@ -4324,7 +4324,7 @@ func (s *DockerSuite) TestRunNamedVolumeNotRemoved(c *check.C) {
|
|||
func (s *DockerSuite) TestRunNamedVolumesFromNotRemoved(c *check.C) {
|
||||
prefix, _ := getPrefixAndSlashFromDaemonPlatform()
|
||||
|
||||
dockerCmd(c, "volume", "create", "--name", "test")
|
||||
dockerCmd(c, "volume", "create", "test")
|
||||
dockerCmd(c, "run", "--name=parent", "-v", "test:"+prefix+"/foo", "-v", prefix+"/bar", "busybox", "true")
|
||||
dockerCmd(c, "run", "--name=child", "--volumes-from=parent", "busybox", "true")
|
||||
|
||||
|
@ -4381,7 +4381,7 @@ func (s *DockerSuite) TestRunVolumeCopyFlag(c *check.C) {
|
|||
)
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
dockerCmd(c, "volume", "create", "--name=test")
|
||||
dockerCmd(c, "volume", "create", "test")
|
||||
|
||||
// test with the nocopy flag
|
||||
out, _, err := dockerCmdWithError("run", "-v", "test:/foo:nocopy", "volumecopy")
|
||||
|
|
|
@ -18,20 +18,29 @@ func (s *DockerSuite) TestVolumeCliCreate(c *check.C) {
|
|||
_, err := runCommand(exec.Command(dockerBinary, "volume", "create", "-d", "nosuchdriver"))
|
||||
c.Assert(err, check.Not(check.IsNil))
|
||||
|
||||
// test using hidden --name option
|
||||
out, _ := dockerCmd(c, "volume", "create", "--name=test")
|
||||
name := strings.TrimSpace(out)
|
||||
c.Assert(name, check.Equals, "test")
|
||||
|
||||
out, _ = dockerCmd(c, "volume", "create", "test2")
|
||||
name = strings.TrimSpace(out)
|
||||
c.Assert(name, check.Equals, "test2")
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestVolumeCliCreateOptionConflict(c *check.C) {
|
||||
dockerCmd(c, "volume", "create", "--name=test")
|
||||
out, _, err := dockerCmdWithError("volume", "create", "--name", "test", "--driver", "nosuchdriver")
|
||||
dockerCmd(c, "volume", "create", "test")
|
||||
out, _, err := dockerCmdWithError("volume", "create", "test", "--driver", "nosuchdriver")
|
||||
c.Assert(err, check.NotNil, check.Commentf("volume create exception name already in use with another driver"))
|
||||
c.Assert(out, checker.Contains, "A volume named test already exists")
|
||||
|
||||
out, _ = dockerCmd(c, "volume", "inspect", "--format={{ .Driver }}", "test")
|
||||
_, _, err = dockerCmdWithError("volume", "create", "--name", "test", "--driver", strings.TrimSpace(out))
|
||||
_, _, err = dockerCmdWithError("volume", "create", "test", "--driver", strings.TrimSpace(out))
|
||||
c.Assert(err, check.IsNil)
|
||||
|
||||
// make sure hidden --name option conflicts with positional arg name
|
||||
out, _, err = dockerCmdWithError("volume", "create", "--name", "test2", "test2")
|
||||
c.Assert(err, check.NotNil, check.Commentf("Conflicting options: either specify --name or provide positional arg, not both"))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestVolumeCliInspect(c *check.C) {
|
||||
|
@ -46,15 +55,15 @@ func (s *DockerSuite) TestVolumeCliInspect(c *check.C) {
|
|||
out, _ = dockerCmd(c, "volume", "inspect", "--format={{ .Name }}", name)
|
||||
c.Assert(strings.TrimSpace(out), check.Equals, name)
|
||||
|
||||
dockerCmd(c, "volume", "create", "--name", "test")
|
||||
dockerCmd(c, "volume", "create", "test")
|
||||
out, _ = dockerCmd(c, "volume", "inspect", "--format={{ .Name }}", "test")
|
||||
c.Assert(strings.TrimSpace(out), check.Equals, "test")
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestVolumeCliInspectMulti(c *check.C) {
|
||||
dockerCmd(c, "volume", "create", "--name", "test1")
|
||||
dockerCmd(c, "volume", "create", "--name", "test2")
|
||||
dockerCmd(c, "volume", "create", "--name", "not-shown")
|
||||
dockerCmd(c, "volume", "create", "test1")
|
||||
dockerCmd(c, "volume", "create", "test2")
|
||||
dockerCmd(c, "volume", "create", "not-shown")
|
||||
|
||||
result := dockerCmdWithResult("volume", "inspect", "--format={{ .Name }}", "test1", "test2", "doesntexist", "not-shown")
|
||||
c.Assert(result, icmd.Matches, icmd.Expected{
|
||||
|
@ -73,11 +82,11 @@ func (s *DockerSuite) TestVolumeCliInspectMulti(c *check.C) {
|
|||
|
||||
func (s *DockerSuite) TestVolumeCliLs(c *check.C) {
|
||||
prefix, _ := getPrefixAndSlashFromDaemonPlatform()
|
||||
dockerCmd(c, "volume", "create", "--name", "aaa")
|
||||
dockerCmd(c, "volume", "create", "aaa")
|
||||
|
||||
dockerCmd(c, "volume", "create", "--name", "test")
|
||||
dockerCmd(c, "volume", "create", "test")
|
||||
|
||||
dockerCmd(c, "volume", "create", "--name", "soo")
|
||||
dockerCmd(c, "volume", "create", "soo")
|
||||
dockerCmd(c, "run", "-v", "soo:"+prefix+"/foo", "busybox", "ls", "/")
|
||||
|
||||
out, _ := dockerCmd(c, "volume", "ls")
|
||||
|
@ -88,9 +97,9 @@ func (s *DockerSuite) TestVolumeCliLs(c *check.C) {
|
|||
}
|
||||
|
||||
func (s *DockerSuite) TestVolumeLsFormat(c *check.C) {
|
||||
dockerCmd(c, "volume", "create", "--name", "aaa")
|
||||
dockerCmd(c, "volume", "create", "--name", "test")
|
||||
dockerCmd(c, "volume", "create", "--name", "soo")
|
||||
dockerCmd(c, "volume", "create", "aaa")
|
||||
dockerCmd(c, "volume", "create", "test")
|
||||
dockerCmd(c, "volume", "create", "soo")
|
||||
|
||||
out, _ := dockerCmd(c, "volume", "ls", "--format", "{{.Name}}")
|
||||
lines := strings.Split(strings.TrimSpace(string(out)), "\n")
|
||||
|
@ -104,9 +113,9 @@ func (s *DockerSuite) TestVolumeLsFormat(c *check.C) {
|
|||
}
|
||||
|
||||
func (s *DockerSuite) TestVolumeLsFormatDefaultFormat(c *check.C) {
|
||||
dockerCmd(c, "volume", "create", "--name", "aaa")
|
||||
dockerCmd(c, "volume", "create", "--name", "test")
|
||||
dockerCmd(c, "volume", "create", "--name", "soo")
|
||||
dockerCmd(c, "volume", "create", "aaa")
|
||||
dockerCmd(c, "volume", "create", "test")
|
||||
dockerCmd(c, "volume", "create", "soo")
|
||||
|
||||
config := `{
|
||||
"volumesFormat": "{{ .Name }} default"
|
||||
|
@ -147,9 +156,9 @@ func assertVolList(c *check.C, out string, expectVols []string) {
|
|||
|
||||
func (s *DockerSuite) TestVolumeCliLsFilterDangling(c *check.C) {
|
||||
prefix, _ := getPrefixAndSlashFromDaemonPlatform()
|
||||
dockerCmd(c, "volume", "create", "--name", "testnotinuse1")
|
||||
dockerCmd(c, "volume", "create", "--name", "testisinuse1")
|
||||
dockerCmd(c, "volume", "create", "--name", "testisinuse2")
|
||||
dockerCmd(c, "volume", "create", "testnotinuse1")
|
||||
dockerCmd(c, "volume", "create", "testisinuse1")
|
||||
dockerCmd(c, "volume", "create", "testisinuse2")
|
||||
|
||||
// Make sure both "created" (but not started), and started
|
||||
// containers are included in reference counting
|
||||
|
@ -225,7 +234,7 @@ func (s *DockerSuite) TestVolumeCliRm(c *check.C) {
|
|||
out, _ := dockerCmd(c, "volume", "create")
|
||||
id := strings.TrimSpace(out)
|
||||
|
||||
dockerCmd(c, "volume", "create", "--name", "test")
|
||||
dockerCmd(c, "volume", "create", "test")
|
||||
dockerCmd(c, "volume", "rm", id)
|
||||
dockerCmd(c, "volume", "rm", "test")
|
||||
|
||||
|
@ -290,7 +299,7 @@ func (s *DockerSuite) TestVolumeCliInspectTmplError(c *check.C) {
|
|||
func (s *DockerSuite) TestVolumeCliCreateWithOpts(c *check.C) {
|
||||
testRequires(c, DaemonIsLinux)
|
||||
|
||||
dockerCmd(c, "volume", "create", "-d", "local", "--name", "test", "--opt=type=tmpfs", "--opt=device=tmpfs", "--opt=o=size=1m,uid=1000")
|
||||
dockerCmd(c, "volume", "create", "-d", "local", "test", "--opt=type=tmpfs", "--opt=device=tmpfs", "--opt=o=size=1m,uid=1000")
|
||||
out, _ := dockerCmd(c, "run", "-v", "test:/foo", "busybox", "mount")
|
||||
|
||||
mounts := strings.Split(out, "\n")
|
||||
|
@ -315,7 +324,7 @@ func (s *DockerSuite) TestVolumeCliCreateLabel(c *check.C) {
|
|||
testLabel := "foo"
|
||||
testValue := "bar"
|
||||
|
||||
out, _, err := dockerCmdWithError("volume", "create", "--label", testLabel+"="+testValue, "--name", testVol)
|
||||
out, _, err := dockerCmdWithError("volume", "create", "--label", testLabel+"="+testValue, testVol)
|
||||
c.Assert(err, check.IsNil)
|
||||
|
||||
out, _ = dockerCmd(c, "volume", "inspect", "--format={{ .Labels."+testLabel+" }}", testVol)
|
||||
|
@ -333,7 +342,6 @@ func (s *DockerSuite) TestVolumeCliCreateLabelMultiple(c *check.C) {
|
|||
args := []string{
|
||||
"volume",
|
||||
"create",
|
||||
"--name",
|
||||
testVol,
|
||||
}
|
||||
|
||||
|
@ -352,11 +360,11 @@ func (s *DockerSuite) TestVolumeCliCreateLabelMultiple(c *check.C) {
|
|||
|
||||
func (s *DockerSuite) TestVolumeCliLsFilterLabels(c *check.C) {
|
||||
testVol1 := "testvolcreatelabel-1"
|
||||
out, _, err := dockerCmdWithError("volume", "create", "--label", "foo=bar1", "--name", testVol1)
|
||||
out, _, err := dockerCmdWithError("volume", "create", "--label", "foo=bar1", testVol1)
|
||||
c.Assert(err, check.IsNil)
|
||||
|
||||
testVol2 := "testvolcreatelabel-2"
|
||||
out, _, err = dockerCmdWithError("volume", "create", "--label", "foo=bar2", "--name", testVol2)
|
||||
out, _, err = dockerCmdWithError("volume", "create", "--label", "foo=bar2", testVol2)
|
||||
c.Assert(err, check.IsNil)
|
||||
|
||||
out, _ = dockerCmd(c, "volume", "ls", "--filter", "label=foo")
|
||||
|
@ -396,7 +404,7 @@ func (s *DockerSuite) TestVolumeCliRmForce(c *check.C) {
|
|||
testRequires(c, SameHostDaemon, DaemonIsLinux)
|
||||
|
||||
name := "test"
|
||||
out, _ := dockerCmd(c, "volume", "create", "--name", name)
|
||||
out, _ := dockerCmd(c, "volume", "create", name)
|
||||
id := strings.TrimSpace(out)
|
||||
c.Assert(id, checker.Equals, name)
|
||||
|
||||
|
@ -410,7 +418,7 @@ func (s *DockerSuite) TestVolumeCliRmForce(c *check.C) {
|
|||
dockerCmd(c, "volume", "rm", "-f", "test")
|
||||
out, _ = dockerCmd(c, "volume", "ls")
|
||||
c.Assert(out, checker.Not(checker.Contains), name)
|
||||
dockerCmd(c, "volume", "create", "--name", "test")
|
||||
dockerCmd(c, "volume", "create", "test")
|
||||
out, _ = dockerCmd(c, "volume", "ls")
|
||||
c.Assert(out, checker.Contains, name)
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче