Browse code

Move more 'daemon' errors to the new error package

Signed-off-by: Doug Davis <dug@us.ibm.com>

Doug Davis authored on 2015/09/19 02:48:16
Showing 12 changed files
... ...
@@ -18,6 +18,7 @@ import (
18 18
 	"github.com/docker/docker/context"
19 19
 	"github.com/docker/docker/daemon"
20 20
 	"github.com/docker/docker/pkg/sockets"
21
+	"github.com/docker/docker/utils"
21 22
 )
22 23
 
23 24
 // Config provides the configuration for the API server
... ...
@@ -248,7 +249,7 @@ func httpError(w http.ResponseWriter, err error) {
248 248
 		statusCode = http.StatusInternalServerError
249 249
 	}
250 250
 
251
-	logrus.WithFields(logrus.Fields{"statusCode": statusCode, "err": err}).Error("HTTP Error")
251
+	logrus.WithFields(logrus.Fields{"statusCode": statusCode, "err": utils.GetErrorMessage(err)}).Error("HTTP Error")
252 252
 	http.Error(w, errMsg, statusCode)
253 253
 }
254 254
 
... ...
@@ -305,7 +306,7 @@ func (s *Server) makeHTTPHandler(localMethod string, localRoute string, localHan
305 305
 		handlerFunc := s.handleWithGlobalMiddlewares(localHandler)
306 306
 
307 307
 		if err := handlerFunc(ctx, w, r, mux.Vars(r)); err != nil {
308
-			logrus.Errorf("Handler for %s %s returned error: %s", localMethod, localRoute, err)
308
+			logrus.Errorf("Handler for %s %s returned error: %s", localMethod, localRoute, utils.GetErrorMessage(err))
309 309
 			httpError(w, err)
310 310
 		}
311 311
 	}
... ...
@@ -973,7 +973,7 @@ func (container *Container) setNetworkNamespaceKey(pid int) error {
973 973
 	search := libnetwork.SandboxContainerWalker(&sandbox, container.ID)
974 974
 	container.daemon.netController.WalkSandboxes(search)
975 975
 	if sandbox == nil {
976
-		return fmt.Errorf("no sandbox present for %s", container.ID)
976
+		return derr.ErrorCodeNoSandbox.WithArgs(container.ID)
977 977
 	}
978 978
 
979 979
 	return sandbox.SetKey(path)
... ...
@@ -6,6 +6,7 @@ import (
6 6
 	"path"
7 7
 
8 8
 	"github.com/Sirupsen/logrus"
9
+	derr "github.com/docker/docker/errors"
9 10
 	"github.com/docker/docker/volume/store"
10 11
 )
11 12
 
... ...
@@ -31,11 +32,11 @@ func (daemon *Daemon) ContainerRm(name string, config *ContainerRmConfig) error
31 31
 		}
32 32
 		parent, n := path.Split(name)
33 33
 		if parent == "/" {
34
-			return fmt.Errorf("Conflict, cannot remove the default name of the container")
34
+			return derr.ErrorCodeDefaultName
35 35
 		}
36 36
 		pe := daemon.containerGraph().Get(parent)
37 37
 		if pe == nil {
38
-			return fmt.Errorf("Cannot get parent %s for name %s", parent, name)
38
+			return derr.ErrorCodeNoParent.WithArgs(parent, name)
39 39
 		}
40 40
 
41 41
 		if err := daemon.containerGraph().Delete(name); err != nil {
... ...
@@ -53,7 +54,8 @@ func (daemon *Daemon) ContainerRm(name string, config *ContainerRmConfig) error
53 53
 	}
54 54
 
55 55
 	if err := daemon.rm(container, config.ForceRemove); err != nil {
56
-		return fmt.Errorf("Cannot destroy container %s: %v", name, err)
56
+		// return derr.ErrorCodeCantDestroy.WithArgs(name, utils.GetErrorMessage(err))
57
+		return err
57 58
 	}
58 59
 
59 60
 	if err := container.removeMountPoints(config.RemoveVolume); err != nil {
... ...
@@ -67,10 +69,10 @@ func (daemon *Daemon) ContainerRm(name string, config *ContainerRmConfig) error
67 67
 func (daemon *Daemon) rm(container *Container, forceRemove bool) (err error) {
68 68
 	if container.IsRunning() {
69 69
 		if !forceRemove {
70
-			return fmt.Errorf("Conflict, You cannot remove a running container. Stop the container before attempting removal or use -f")
70
+			return derr.ErrorCodeRmRunning
71 71
 		}
72 72
 		if err := container.Kill(); err != nil {
73
-			return fmt.Errorf("Could not kill running container, cannot remove - %v", err)
73
+			return derr.ErrorCodeRmFailed.WithArgs(err)
74 74
 		}
75 75
 	}
76 76
 
... ...
@@ -80,12 +82,12 @@ func (daemon *Daemon) rm(container *Container, forceRemove bool) (err error) {
80 80
 
81 81
 	element := daemon.containers.Get(container.ID)
82 82
 	if element == nil {
83
-		return fmt.Errorf("Container %v not found - maybe it was already destroyed?", container.ID)
83
+		return derr.ErrorCodeRmNotFound.WithArgs(container.ID)
84 84
 	}
85 85
 
86 86
 	// Container state RemovalInProgress should be used to avoid races.
87 87
 	if err = container.setRemovalInProgress(); err != nil {
88
-		return fmt.Errorf("Failed to set container state to RemovalInProgress: %s", err)
88
+		return derr.ErrorCodeRmState.WithArgs(err)
89 89
 	}
90 90
 
91 91
 	defer container.resetRemovalInProgress()
... ...
@@ -120,20 +122,20 @@ func (daemon *Daemon) rm(container *Container, forceRemove bool) (err error) {
120 120
 	}
121 121
 
122 122
 	if err = daemon.driver.Remove(container.ID); err != nil {
123
-		return fmt.Errorf("Driver %s failed to remove root filesystem %s: %s", daemon.driver, container.ID, err)
123
+		return derr.ErrorCodeRmDriverFS.WithArgs(daemon.driver, container.ID, err)
124 124
 	}
125 125
 
126 126
 	initID := fmt.Sprintf("%s-init", container.ID)
127 127
 	if err := daemon.driver.Remove(initID); err != nil {
128
-		return fmt.Errorf("Driver %s failed to remove init filesystem %s: %s", daemon.driver, initID, err)
128
+		return derr.ErrorCodeRmInit.WithArgs(daemon.driver, initID, err)
129 129
 	}
130 130
 
131 131
 	if err = os.RemoveAll(container.root); err != nil {
132
-		return fmt.Errorf("Unable to remove filesystem for %v: %v", container.ID, err)
132
+		return derr.ErrorCodeRmFS.WithArgs(container.ID, err)
133 133
 	}
134 134
 
135 135
 	if err = daemon.execDriver.Clean(container.ID); err != nil {
136
-		return fmt.Errorf("Unable to remove execdriver data for %s: %s", container.ID, err)
136
+		return derr.ErrorCodeRmExecDriver.WithArgs(container.ID, err)
137 137
 	}
138 138
 
139 139
 	selinuxFreeLxcContexts(container.ProcessLabel)
... ...
@@ -154,9 +156,9 @@ func (daemon *Daemon) VolumeRm(name string) error {
154 154
 	}
155 155
 	if err := daemon.volumes.Remove(v); err != nil {
156 156
 		if err == store.ErrVolumeInUse {
157
-			return fmt.Errorf("Conflict: %v", err)
157
+			return derr.ErrorCodeRmVolumeInUse.WithArgs(err)
158 158
 		}
159
-		return fmt.Errorf("Error while removing volume %s: %v", name, err)
159
+		return derr.ErrorCodeRmVolume.WithArgs(name, err)
160 160
 	}
161 161
 	return nil
162 162
 }
... ...
@@ -1,7 +1,6 @@
1 1
 package daemon
2 2
 
3 3
 import (
4
-	"fmt"
5 4
 	"io"
6 5
 	"io/ioutil"
7 6
 	"strings"
... ...
@@ -10,6 +9,7 @@ import (
10 10
 
11 11
 	"github.com/Sirupsen/logrus"
12 12
 	"github.com/docker/docker/daemon/execdriver"
13
+	derr "github.com/docker/docker/errors"
13 14
 	"github.com/docker/docker/pkg/broadcastwriter"
14 15
 	"github.com/docker/docker/pkg/ioutils"
15 16
 	"github.com/docker/docker/pkg/pools"
... ...
@@ -80,7 +80,7 @@ func (ExecConfig *ExecConfig) resize(h, w int) error {
80 80
 	select {
81 81
 	case <-ExecConfig.waitStart:
82 82
 	case <-time.After(time.Second):
83
-		return fmt.Errorf("Exec %s is not running, so it can not be resized.", ExecConfig.ID)
83
+		return derr.ErrorCodeExecResize.WithArgs(ExecConfig.ID)
84 84
 	}
85 85
 	return ExecConfig.ProcessConfig.Terminal.Resize(h, w)
86 86
 }
... ...
@@ -104,12 +104,12 @@ func (d *Daemon) getExecConfig(name string) (*ExecConfig, error) {
104 104
 	if ExecConfig != nil && d.containers.Get(ExecConfig.Container.ID) != nil {
105 105
 
106 106
 		if !ExecConfig.Container.IsRunning() {
107
-			return nil, fmt.Errorf("Container %s is not running", ExecConfig.Container.ID)
107
+			return nil, derr.ErrorCodeContainerNotRunning.WithArgs(ExecConfig.Container.ID)
108 108
 		}
109 109
 		return ExecConfig, nil
110 110
 	}
111 111
 
112
-	return nil, fmt.Errorf("No such exec instance '%s' found in daemon", name)
112
+	return nil, derr.ErrorCodeNoExecID.WithArgs(name)
113 113
 }
114 114
 
115 115
 func (d *Daemon) unregisterExecCommand(ExecConfig *ExecConfig) {
... ...
@@ -124,10 +124,10 @@ func (d *Daemon) getActiveContainer(name string) (*Container, error) {
124 124
 	}
125 125
 
126 126
 	if !container.IsRunning() {
127
-		return nil, fmt.Errorf("Container %s is not running", name)
127
+		return nil, derr.ErrorCodeNotRunning.WithArgs(name)
128 128
 	}
129 129
 	if container.isPaused() {
130
-		return nil, fmt.Errorf("Container %s is paused, unpause the container before exec", name)
130
+		return nil, derr.ErrorCodeExecPaused.WithArgs(name)
131 131
 	}
132 132
 	return container, nil
133 133
 }
... ...
@@ -196,7 +196,7 @@ func (d *Daemon) ContainerExecStart(execName string, stdin io.ReadCloser, stdout
196 196
 		ExecConfig.Lock()
197 197
 		defer ExecConfig.Unlock()
198 198
 		if ExecConfig.Running {
199
-			err = fmt.Errorf("Error: Exec command %s is already running", execName)
199
+			err = derr.ErrorCodeExecRunning.WithArgs(execName)
200 200
 		}
201 201
 		ExecConfig.Running = true
202 202
 	}()
... ...
@@ -244,13 +244,13 @@ func (d *Daemon) ContainerExecStart(execName string, stdin io.ReadCloser, stdout
244 244
 
245 245
 	go func() {
246 246
 		if err := container.exec(ExecConfig); err != nil {
247
-			execErr <- fmt.Errorf("Cannot run exec command %s in container %s: %s", execName, container.ID, err)
247
+			execErr <- derr.ErrorCodeExecCantRun.WithArgs(execName, container.ID, err)
248 248
 		}
249 249
 	}()
250 250
 	select {
251 251
 	case err := <-attachErr:
252 252
 		if err != nil {
253
-			return fmt.Errorf("attach failed with error: %s", err)
253
+			return derr.ErrorCodeExecAttach.WithArgs(err)
254 254
 		}
255 255
 		return nil
256 256
 	case err := <-execErr:
... ...
@@ -260,7 +260,7 @@ func (d *Daemon) ContainerExecStart(execName string, stdin io.ReadCloser, stdout
260 260
 
261 261
 		// Maybe the container stopped while we were trying to exec
262 262
 		if !container.IsRunning() {
263
-			return fmt.Errorf("container stopped while running exec")
263
+			return derr.ErrorCodeExecContainerStopped
264 264
 		}
265 265
 		return err
266 266
 	}
... ...
@@ -1,8 +1,9 @@
1 1
 package daemon
2 2
 
3 3
 import (
4
-	"fmt"
5 4
 	"io"
5
+
6
+	derr "github.com/docker/docker/errors"
6 7
 )
7 8
 
8 9
 // ContainerExport writes the contents of the container to the given
... ...
@@ -15,13 +16,13 @@ func (daemon *Daemon) ContainerExport(name string, out io.Writer) error {
15 15
 
16 16
 	data, err := container.export()
17 17
 	if err != nil {
18
-		return fmt.Errorf("%s: %s", name, err)
18
+		return derr.ErrorCodeExportFailed.WithArgs(name, err)
19 19
 	}
20 20
 	defer data.Close()
21 21
 
22 22
 	// Stream the entire contents of the container (basically a volatile snapshot)
23 23
 	if _, err := io.Copy(out, data); err != nil {
24
-		return fmt.Errorf("%s: %s", name, err)
24
+		return derr.ErrorCodeExportFailed.WithArgs(name, err)
25 25
 	}
26 26
 	return nil
27 27
 }
... ...
@@ -5,6 +5,7 @@ import (
5 5
 	"strings"
6 6
 
7 7
 	"github.com/docker/docker/api/types"
8
+	derr "github.com/docker/docker/errors"
8 9
 	"github.com/docker/docker/graph/tags"
9 10
 	"github.com/docker/docker/image"
10 11
 	"github.com/docker/docker/pkg/parsers"
... ...
@@ -69,7 +70,7 @@ func (daemon *Daemon) ImageDelete(imageRef string, force, prune bool) ([]types.I
69 69
 				// this image would remain "dangling" and since
70 70
 				// we really want to avoid that the client must
71 71
 				// explicitly force its removal.
72
-				return nil, fmt.Errorf("conflict: unable to remove repository reference %q (must force) - container %s is using its referenced image %s", imageRef, stringid.TruncateID(container.ID), stringid.TruncateID(img.ID))
72
+				return nil, derr.ErrorCodeImgDelUsed.WithArgs(imageRef, stringid.TruncateID(container.ID), stringid.TruncateID(img.ID))
73 73
 			}
74 74
 		}
75 75
 
... ...
@@ -238,7 +239,7 @@ func (daemon *Daemon) imageDeleteHelper(img *image.Image, records *[]types.Image
238 238
 	// either running or stopped).
239 239
 	parentImg, err := daemon.Graph().Get(img.Parent)
240 240
 	if err != nil {
241
-		return fmt.Errorf("unable to get parent image: %v", err)
241
+		return derr.ErrorCodeImgNoParent.WithArgs(err)
242 242
 	}
243 243
 
244 244
 	// Do not force prunings, but do so quietly (stopping on any encountered
... ...
@@ -8,6 +8,7 @@ import (
8 8
 
9 9
 	"github.com/Sirupsen/logrus"
10 10
 	"github.com/docker/docker/api/types"
11
+	derr "github.com/docker/docker/errors"
11 12
 	"github.com/docker/docker/image"
12 13
 	"github.com/docker/docker/pkg/graphdb"
13 14
 	"github.com/docker/docker/pkg/nat"
... ...
@@ -370,7 +371,7 @@ func (daemon *Daemon) Volumes(filter string) ([]*types.Volume, error) {
370 370
 	filterUsed := false
371 371
 	if i, ok := volFilters["dangling"]; ok {
372 372
 		if len(i) > 1 {
373
-			return nil, fmt.Errorf("Conflict: cannot use more than 1 value for `dangling` filter")
373
+			return nil, derr.ErrorCodeDanglingOne
374 374
 		}
375 375
 
376 376
 		filterValue := i[0]
... ...
@@ -1,13 +1,13 @@
1 1
 package daemon
2 2
 
3 3
 import (
4
-	"fmt"
5 4
 	"io"
6 5
 	"strconv"
7 6
 	"time"
8 7
 
9 8
 	"github.com/Sirupsen/logrus"
10 9
 	"github.com/docker/docker/daemon/logger"
10
+	derr "github.com/docker/docker/errors"
11 11
 	"github.com/docker/docker/pkg/stdcopy"
12 12
 )
13 13
 
... ...
@@ -32,7 +32,7 @@ type ContainerLogsConfig struct {
32 32
 // configured with the given struct.
33 33
 func (daemon *Daemon) ContainerLogs(container *Container, config *ContainerLogsConfig) error {
34 34
 	if !(config.UseStdout || config.UseStderr) {
35
-		return fmt.Errorf("You must choose at least one stream")
35
+		return derr.ErrorCodeNeedStream
36 36
 	}
37 37
 
38 38
 	outStream := config.OutStream
... ...
@@ -1,6 +1,8 @@
1 1
 package daemon
2 2
 
3
-import "fmt"
3
+import (
4
+	derr "github.com/docker/docker/errors"
5
+)
4 6
 
5 7
 // ContainerPause pauses a container
6 8
 func (daemon *Daemon) ContainerPause(name string) error {
... ...
@@ -10,7 +12,7 @@ func (daemon *Daemon) ContainerPause(name string) error {
10 10
 	}
11 11
 
12 12
 	if err := container.pause(); err != nil {
13
-		return fmt.Errorf("Cannot pause container %s: %s", name, err)
13
+		return derr.ErrorCodePauseError.WithArgs(name, err)
14 14
 	}
15 15
 
16 16
 	return nil
... ...
@@ -1,7 +1,7 @@
1 1
 package daemon
2 2
 
3 3
 import (
4
-	"fmt"
4
+	derr "github.com/docker/docker/errors"
5 5
 )
6 6
 
7 7
 // ContainerRename changes the name of a container, using the oldName
... ...
@@ -9,7 +9,7 @@ import (
9 9
 // reserved.
10 10
 func (daemon *Daemon) ContainerRename(oldName, newName string) error {
11 11
 	if oldName == "" || newName == "" {
12
-		return fmt.Errorf("Neither old nor new names may be empty")
12
+		return derr.ErrorCodeEmptyRename
13 13
 	}
14 14
 
15 15
 	container, err := daemon.Get(oldName)
... ...
@@ -22,7 +22,7 @@ func (daemon *Daemon) ContainerRename(oldName, newName string) error {
22 22
 	container.Lock()
23 23
 	defer container.Unlock()
24 24
 	if newName, err = daemon.reserveName(container.ID, newName); err != nil {
25
-		return fmt.Errorf("Error when allocating new name: %s", err)
25
+		return derr.ErrorCodeRenameTaken.WithArgs(err)
26 26
 	}
27 27
 
28 28
 	container.Name = newName
... ...
@@ -35,7 +35,7 @@ func (daemon *Daemon) ContainerRename(oldName, newName string) error {
35 35
 
36 36
 	if err := daemon.containerGraphDB.Delete(oldName); err != nil {
37 37
 		undo()
38
-		return fmt.Errorf("Failed to delete container %q: %v", oldName, err)
38
+		return derr.ErrorCodeRenameDelete.WithArgs(oldName, err)
39 39
 	}
40 40
 
41 41
 	if err := container.toDisk(); err != nil {
... ...
@@ -1,6 +1,8 @@
1 1
 package daemon
2 2
 
3
-import "fmt"
3
+import (
4
+	derr "github.com/docker/docker/errors"
5
+)
4 6
 
5 7
 // ContainerRestart stops and starts a container. It attempts to
6 8
 // gracefully stop the container within the given timeout, forcefully
... ...
@@ -14,7 +16,7 @@ func (daemon *Daemon) ContainerRestart(name string, seconds int) error {
14 14
 		return err
15 15
 	}
16 16
 	if err := container.Restart(seconds); err != nil {
17
-		return fmt.Errorf("Cannot restart container %s: %s\n", name, err)
17
+		return derr.ErrorCodeCantRestart.WithArgs(name, err)
18 18
 	}
19 19
 	return nil
20 20
 }
... ...
@@ -24,6 +24,7 @@ var (
24 24
 	ErrorCodeUnregisteredContainer = errcode.Register(errGroup, errcode.ErrorDescriptor{
25 25
 		Value:          "UNREGISTEREDCONTAINER",
26 26
 		Message:        "Can't load storage driver for unregistered container %s",
27
+		Description:    "An attempt was made to load the storage driver for a container that is not registered with the daemon",
27 28
 		HTTPStatusCode: http.StatusInternalServerError,
28 29
 	})
29 30
 
... ...
@@ -32,6 +33,7 @@ var (
32 32
 	ErrorCodeContainerBeingRemoved = errcode.Register(errGroup, errcode.ErrorDescriptor{
33 33
 		Value:          "CONTAINERBEINGREMOVED",
34 34
 		Message:        "Container is marked for removal and cannot be started.",
35
+		Description:    "An attempt was made to start a container that is in the process of being deleted",
35 36
 		HTTPStatusCode: http.StatusInternalServerError,
36 37
 	})
37 38
 
... ...
@@ -40,6 +42,7 @@ var (
40 40
 	ErrorCodeUnpauseContainer = errcode.Register(errGroup, errcode.ErrorDescriptor{
41 41
 		Value:          "UNPAUSECONTAINER",
42 42
 		Message:        "Container %s is paused. Unpause the container before stopping",
43
+		Description:    "The specified container is paused, before it can be stopped it must be unpaused",
43 44
 		HTTPStatusCode: http.StatusInternalServerError,
44 45
 	})
45 46
 
... ...
@@ -48,6 +51,7 @@ var (
48 48
 	ErrorCodeAlreadyPaused = errcode.Register(errGroup, errcode.ErrorDescriptor{
49 49
 		Value:          "ALREADYPAUSED",
50 50
 		Message:        "Container %s is already paused",
51
+		Description:    "The specified container is already in the paused state",
51 52
 		HTTPStatusCode: http.StatusInternalServerError,
52 53
 	})
53 54
 
... ...
@@ -56,6 +60,7 @@ var (
56 56
 	ErrorCodeNotPaused = errcode.Register(errGroup, errcode.ErrorDescriptor{
57 57
 		Value:          "NOTPAUSED",
58 58
 		Message:        "Container %s is not paused",
59
+		Description:    "The specified container can not be unpaused because it is not in a paused state",
59 60
 		HTTPStatusCode: http.StatusInternalServerError,
60 61
 	})
61 62
 
... ...
@@ -64,6 +69,7 @@ var (
64 64
 	ErrorCodeImageUnregContainer = errcode.Register(errGroup, errcode.ErrorDescriptor{
65 65
 		Value:          "IMAGEUNREGCONTAINER",
66 66
 		Message:        "Can't get image of unregistered container",
67
+		Description:    "An attempt to retrieve the image of a container was made but the container is not registered",
67 68
 		HTTPStatusCode: http.StatusInternalServerError,
68 69
 	})
69 70
 
... ...
@@ -71,6 +77,7 @@ var (
71 71
 	ErrorCodeEmptyID = errcode.Register(errGroup, errcode.ErrorDescriptor{
72 72
 		Value:          "EMPTYID",
73 73
 		Message:        "Invalid empty id",
74
+		Description:    "An attempt was made to register a container but the container's ID can not be an empty string",
74 75
 		HTTPStatusCode: http.StatusInternalServerError,
75 76
 	})
76 77
 
... ...
@@ -79,6 +86,7 @@ var (
79 79
 	ErrorCodeLoggingFactory = errcode.Register(errGroup, errcode.ErrorDescriptor{
80 80
 		Value:          "LOGGINGFACTORY",
81 81
 		Message:        "Failed to get logging factory: %v",
82
+		Description:    "An attempt was made to register a container but the container's ID can not be an empty string",
82 83
 		HTTPStatusCode: http.StatusInternalServerError,
83 84
 	})
84 85
 
... ...
@@ -87,6 +95,7 @@ var (
87 87
 	ErrorCodeInitLogger = errcode.Register(errGroup, errcode.ErrorDescriptor{
88 88
 		Value:          "INITLOGGER",
89 89
 		Message:        "Failed to initialize logging driver: %v",
90
+		Description:    "An error occurred while trying to initialize the logging driver",
90 91
 		HTTPStatusCode: http.StatusInternalServerError,
91 92
 	})
92 93
 
... ...
@@ -95,6 +104,7 @@ var (
95 95
 	ErrorCodeNotRunning = errcode.Register(errGroup, errcode.ErrorDescriptor{
96 96
 		Value:          "NOTRUNNING",
97 97
 		Message:        "Container %s is not running",
98
+		Description:    "The specified action can not be taken due to the container not being in a running state",
98 99
 		HTTPStatusCode: http.StatusInternalServerError,
99 100
 	})
100 101
 
... ...
@@ -103,6 +113,7 @@ var (
103 103
 	ErrorCodeLinkNotRunning = errcode.Register(errGroup, errcode.ErrorDescriptor{
104 104
 		Value:          "LINKNOTRUNNING",
105 105
 		Message:        "Cannot link to a non running container: %s AS %s",
106
+		Description:    "An attempt was made to link to a container but the container is not in a running state",
106 107
 		HTTPStatusCode: http.StatusInternalServerError,
107 108
 	})
108 109
 
... ...
@@ -112,6 +123,7 @@ var (
112 112
 	ErrorCodeDeviceInfo = errcode.Register(errGroup, errcode.ErrorDescriptor{
113 113
 		Value:          "DEVICEINFO",
114 114
 		Message:        "error gathering device information while adding custom device %q: %s",
115
+		Description:    "There was an error while trying to retrieve the information about a custom device",
115 116
 		HTTPStatusCode: http.StatusInternalServerError,
116 117
 	})
117 118
 
... ...
@@ -120,6 +132,7 @@ var (
120 120
 	ErrorCodeEmptyEndpoint = errcode.Register(errGroup, errcode.ErrorDescriptor{
121 121
 		Value:          "EMPTYENDPOINT",
122 122
 		Message:        "invalid endpoint while building port map info",
123
+		Description:    "The specified endpoint for the port mapping is empty",
123 124
 		HTTPStatusCode: http.StatusInternalServerError,
124 125
 	})
125 126
 
... ...
@@ -128,6 +141,7 @@ var (
128 128
 	ErrorCodeEmptyNetwork = errcode.Register(errGroup, errcode.ErrorDescriptor{
129 129
 		Value:          "EMPTYNETWORK",
130 130
 		Message:        "invalid networksettings while building port map info",
131
+		Description:    "The specified endpoint for the port mapping is empty",
131 132
 		HTTPStatusCode: http.StatusInternalServerError,
132 133
 	})
133 134
 
... ...
@@ -136,6 +150,7 @@ var (
136 136
 	ErrorCodeParsingPort = errcode.Register(errGroup, errcode.ErrorDescriptor{
137 137
 		Value:          "PARSINGPORT",
138 138
 		Message:        "Error parsing Port value(%v):%v",
139
+		Description:    "There was an error while trying to parse the specified 'port' value",
139 140
 		HTTPStatusCode: http.StatusInternalServerError,
140 141
 	})
141 142
 
... ...
@@ -144,6 +159,7 @@ var (
144 144
 	ErrorCodeNoSandbox = errcode.Register(errGroup, errcode.ErrorDescriptor{
145 145
 		Value:          "NOSANDBOX",
146 146
 		Message:        "error locating sandbox id %s: %v",
147
+		Description:    "There was an error trying to located the specified networking sandbox",
147 148
 		HTTPStatusCode: http.StatusInternalServerError,
148 149
 	})
149 150
 
... ...
@@ -152,6 +168,7 @@ var (
152 152
 	ErrorCodeNetworkUpdate = errcode.Register(errGroup, errcode.ErrorDescriptor{
153 153
 		Value:          "NETWORKUPDATE",
154 154
 		Message:        "Update network failed: %v",
155
+		Description:    "There was an error trying to update the configuration information of the specified network sandbox",
155 156
 		HTTPStatusCode: http.StatusInternalServerError,
156 157
 	})
157 158
 
... ...
@@ -160,22 +177,25 @@ var (
160 160
 	ErrorCodeNetworkRefresh = errcode.Register(errGroup, errcode.ErrorDescriptor{
161 161
 		Value:          "NETWORKREFRESH",
162 162
 		Message:        "Update network failed: Failure in refresh sandbox %s: %v",
163
+		Description:    "There was an error trying to refresh the configuration information of the specified network sandbox",
163 164
 		HTTPStatusCode: http.StatusInternalServerError,
164 165
 	})
165 166
 
166 167
 	// ErrorCodeHostPort is generated when there was an error while trying
167
-	// to parse a "host/por" string.
168
+	// to parse a "host/port" string.
168 169
 	ErrorCodeHostPort = errcode.Register(errGroup, errcode.ErrorDescriptor{
169 170
 		Value:          "HOSTPORT",
170 171
 		Message:        "Error parsing HostPort value(%s):%v",
172
+		Description:    "There was an error trying to parse the specified 'HostPort' value",
171 173
 		HTTPStatusCode: http.StatusInternalServerError,
172 174
 	})
173 175
 
174
-	// ErrorCodeNetworkConflict is generated when we try to public a service
176
+	// ErrorCodeNetworkConflict is generated when we try to publish a service
175 177
 	// in network mode.
176 178
 	ErrorCodeNetworkConflict = errcode.Register(errGroup, errcode.ErrorDescriptor{
177 179
 		Value:          "NETWORKCONFLICT",
178 180
 		Message:        "conflicting options: publishing a service and network mode",
181
+		Description:    "It is not possible to publish a service when it is in network mode",
179 182
 		HTTPStatusCode: http.StatusConflict,
180 183
 	})
181 184
 
... ...
@@ -184,14 +204,16 @@ var (
184 184
 	ErrorCodeJoinInfo = errcode.Register(errGroup, errcode.ErrorDescriptor{
185 185
 		Value:          "JOININFO",
186 186
 		Message:        "Updating join info failed: %v",
187
+		Description:    "There was an error during an attempt update a container's join information",
187 188
 		HTTPStatusCode: http.StatusInternalServerError,
188 189
 	})
189 190
 
190 191
 	// ErrorCodeIPCRunning is generated when we try to join a container's
191
-	// IPC but its running.
192
+	// IPC but its not running.
192 193
 	ErrorCodeIPCRunning = errcode.Register(errGroup, errcode.ErrorDescriptor{
193 194
 		Value:          "IPCRUNNING",
194 195
 		Message:        "cannot join IPC of a non running container: %s",
196
+		Description:    "An attempt was made to join the IPC of a container, but the container is not running",
195 197
 		HTTPStatusCode: http.StatusInternalServerError,
196 198
 	})
197 199
 
... ...
@@ -200,6 +222,7 @@ var (
200 200
 	ErrorCodeNotADir = errcode.Register(errGroup, errcode.ErrorDescriptor{
201 201
 		Value:          "NOTADIR",
202 202
 		Message:        "Cannot mkdir: %s is not a directory",
203
+		Description:    "An attempt was made create a directory, but the location in which it is being created is not a directory",
203 204
 		HTTPStatusCode: http.StatusInternalServerError,
204 205
 	})
205 206
 
... ...
@@ -208,6 +231,7 @@ var (
208 208
 	ErrorCodeParseContainer = errcode.Register(errGroup, errcode.ErrorDescriptor{
209 209
 		Value:          "PARSECONTAINER",
210 210
 		Message:        "no container specified to join network",
211
+		Description:    "The specified reference to a container is missing a ':' as a separator between 'container' and 'name'/'id'",
211 212
 		HTTPStatusCode: http.StatusInternalServerError,
212 213
 	})
213 214
 
... ...
@@ -215,6 +239,7 @@ var (
215 215
 	ErrorCodeJoinSelf = errcode.Register(errGroup, errcode.ErrorDescriptor{
216 216
 		Value:          "JOINSELF",
217 217
 		Message:        "cannot join own network",
218
+		Description:    "An attempt was made to have a container join its own network",
218 219
 		HTTPStatusCode: http.StatusInternalServerError,
219 220
 	})
220 221
 
... ...
@@ -222,6 +247,7 @@ var (
222 222
 	ErrorCodeJoinRunning = errcode.Register(errGroup, errcode.ErrorDescriptor{
223 223
 		Value:          "JOINRUNNING",
224 224
 		Message:        "cannot join network of a non running container: %s",
225
+		Description:    "An attempt to join the network of a container, but that container isn't running",
225 226
 		HTTPStatusCode: http.StatusInternalServerError,
226 227
 	})
227 228
 
... ...
@@ -230,6 +256,7 @@ var (
230 230
 	ErrorCodeModeNotContainer = errcode.Register(errGroup, errcode.ErrorDescriptor{
231 231
 		Value:          "MODENOTCONTAINER",
232 232
 		Message:        "network mode not set to container",
233
+		Description:    "An attempt was made to connect to a container's network but the mode wasn't set to 'container'",
233 234
 		HTTPStatusCode: http.StatusInternalServerError,
234 235
 	})
235 236
 
... ...
@@ -238,6 +265,7 @@ var (
238 238
 	ErrorCodeRemovingVolume = errcode.Register(errGroup, errcode.ErrorDescriptor{
239 239
 		Value:          "REMOVINGVOLUME",
240 240
 		Message:        "Error removing volumes:\n%v",
241
+		Description:    "There was an error while trying to remove the mount point (volume) of a container",
241 242
 		HTTPStatusCode: http.StatusInternalServerError,
242 243
 	})
243 244
 
... ...
@@ -246,6 +274,7 @@ var (
246 246
 	ErrorCodeInvalidNetworkMode = errcode.Register(errGroup, errcode.ErrorDescriptor{
247 247
 		Value:          "INVALIDNETWORKMODE",
248 248
 		Message:        "invalid network mode: %s",
249
+		Description:    "The specified networking mode is not valid",
249 250
 		HTTPStatusCode: http.StatusInternalServerError,
250 251
 	})
251 252
 
... ...
@@ -254,6 +283,7 @@ var (
254 254
 	ErrorCodeGetGraph = errcode.Register(errGroup, errcode.ErrorDescriptor{
255 255
 		Value:          "GETGRAPH",
256 256
 		Message:        "Failed to graph.Get on ImageID %s - %s",
257
+		Description:    "There was an error trying to retrieve the image for the specified image ID",
257 258
 		HTTPStatusCode: http.StatusInternalServerError,
258 259
 	})
259 260
 
... ...
@@ -262,6 +292,7 @@ var (
262 262
 	ErrorCodeGetLayer = errcode.Register(errGroup, errcode.ErrorDescriptor{
263 263
 		Value:          "GETLAYER",
264 264
 		Message:        "Failed to get layer path from graphdriver %s for ImageID %s - %s",
265
+		Description:    "There was an error trying to retrieve the layer of the specified image",
265 266
 		HTTPStatusCode: http.StatusInternalServerError,
266 267
 	})
267 268
 
... ...
@@ -270,6 +301,7 @@ var (
270 270
 	ErrorCodePutLayer = errcode.Register(errGroup, errcode.ErrorDescriptor{
271 271
 		Value:          "PUTLAYER",
272 272
 		Message:        "Failed to put layer path from graphdriver %s for ImageID %s - %s",
273
+		Description:    "There was an error trying to store a layer for the specified image",
273 274
 		HTTPStatusCode: http.StatusInternalServerError,
274 275
 	})
275 276
 
... ...
@@ -278,6 +310,7 @@ var (
278 278
 	ErrorCodeGetLayerMetadata = errcode.Register(errGroup, errcode.ErrorDescriptor{
279 279
 		Value:          "GETLAYERMETADATA",
280 280
 		Message:        "Failed to get layer metadata - %s",
281
+		Description:    "There was an error trying to retrieve the metadata of a layer for the specified image",
281 282
 		HTTPStatusCode: http.StatusInternalServerError,
282 283
 	})
283 284
 
... ...
@@ -286,6 +319,7 @@ var (
286 286
 	ErrorCodeEmptyConfig = errcode.Register(errGroup, errcode.ErrorDescriptor{
287 287
 		Value:          "EMPTYCONFIG",
288 288
 		Message:        "Config cannot be empty in order to create a container",
289
+		Description:    "While trying to create a container, the specified configuration information was empty",
289 290
 		HTTPStatusCode: http.StatusInternalServerError,
290 291
 	})
291 292
 
... ...
@@ -294,6 +328,7 @@ var (
294 294
 	ErrorCodeNoSuchImageHash = errcode.Register(errGroup, errcode.ErrorDescriptor{
295 295
 		Value:          "NOSUCHIMAGEHASH",
296 296
 		Message:        "No such image: %s",
297
+		Description:    "An attempt was made to find an image by its hash, but the lookup failed",
297 298
 		HTTPStatusCode: http.StatusNotFound,
298 299
 	})
299 300
 
... ...
@@ -302,6 +337,7 @@ var (
302 302
 	ErrorCodeNoSuchImageTag = errcode.Register(errGroup, errcode.ErrorDescriptor{
303 303
 		Value:          "NOSUCHIMAGETAG",
304 304
 		Message:        "No such image: %s:%s",
305
+		Description:    "An attempt was made to find an image by its name/tag, but the lookup failed",
305 306
 		HTTPStatusCode: http.StatusNotFound,
306 307
 	})
307 308
 
... ...
@@ -310,14 +346,16 @@ var (
310 310
 	ErrorCodeMountOverFile = errcode.Register(errGroup, errcode.ErrorDescriptor{
311 311
 		Value:          "MOUNTOVERFILE",
312 312
 		Message:        "cannot mount volume over existing file, file exists %s",
313
+		Description:    "An attempt was made to mount a volume at the same location as a pre-existing file",
313 314
 		HTTPStatusCode: http.StatusInternalServerError,
314 315
 	})
315 316
 
316 317
 	// ErrorCodeMountSetup is generated when we can't define a mount point
317
-	// due to the source and destination are defined.
318
+	// due to the source and destination being undefined.
318 319
 	ErrorCodeMountSetup = errcode.Register(errGroup, errcode.ErrorDescriptor{
319 320
 		Value:          "MOUNTSETUP",
320 321
 		Message:        "Unable to setup mount point, neither source nor volume defined",
322
+		Description:    "An attempt was made to setup a mount point, but the source and destination are undefined",
321 323
 		HTTPStatusCode: http.StatusInternalServerError,
322 324
 	})
323 325
 
... ...
@@ -326,6 +364,7 @@ var (
326 326
 	ErrorCodeVolumeInvalidMode = errcode.Register(errGroup, errcode.ErrorDescriptor{
327 327
 		Value:          "VOLUMEINVALIDMODE",
328 328
 		Message:        "invalid mode for volumes-from: %s",
329
+		Description:    "An invalid 'mode' was specified in the mount request",
329 330
 		HTTPStatusCode: http.StatusInternalServerError,
330 331
 	})
331 332
 
... ...
@@ -334,6 +373,7 @@ var (
334 334
 	ErrorCodeVolumeInvalid = errcode.Register(errGroup, errcode.ErrorDescriptor{
335 335
 		Value:          "VOLUMEINVALID",
336 336
 		Message:        "Invalid volume specification: %s",
337
+		Description:    "An invalid 'volume' was specified in the mount request",
337 338
 		HTTPStatusCode: http.StatusInternalServerError,
338 339
 	})
339 340
 
... ...
@@ -341,6 +381,7 @@ var (
341 341
 	ErrorCodeVolumeAbs = errcode.Register(errGroup, errcode.ErrorDescriptor{
342 342
 		Value:          "VOLUMEABS",
343 343
 		Message:        "Invalid volume destination path: %s mount path must be absolute.",
344
+		Description:    "An invalid 'destination' path was specified in the mount request, it must be an absolute path",
344 345
 		HTTPStatusCode: http.StatusInternalServerError,
345 346
 	})
346 347
 
... ...
@@ -348,6 +389,7 @@ var (
348 348
 	ErrorCodeVolumeFromBlank = errcode.Register(errGroup, errcode.ErrorDescriptor{
349 349
 		Value:          "VOLUMEFROMBLANK",
350 350
 		Message:        "malformed volumes-from specification: %s",
351
+		Description:    "An invalid 'destination' path was specified in the mount request, it must not be blank",
351 352
 		HTTPStatusCode: http.StatusInternalServerError,
352 353
 	})
353 354
 
... ...
@@ -356,6 +398,7 @@ var (
356 356
 	ErrorCodeVolumeMode = errcode.Register(errGroup, errcode.ErrorDescriptor{
357 357
 		Value:          "VOLUMEMODE",
358 358
 		Message:        "invalid mode for volumes-from: %s",
359
+		Description:    "An invalid 'mode' path was specified in the mount request",
359 360
 		HTTPStatusCode: http.StatusInternalServerError,
360 361
 	})
361 362
 
... ...
@@ -364,6 +407,7 @@ var (
364 364
 	ErrorCodeVolumeDup = errcode.Register(errGroup, errcode.ErrorDescriptor{
365 365
 		Value:          "VOLUMEDUP",
366 366
 		Message:        "Duplicate bind mount %s",
367
+		Description:    "An attempt was made to mount a volume but the specified destination location is already used in a previous mount",
367 368
 		HTTPStatusCode: http.StatusInternalServerError,
368 369
 	})
369 370
 
... ...
@@ -372,6 +416,7 @@ var (
372 372
 	ErrorCodeCantUnpause = errcode.Register(errGroup, errcode.ErrorDescriptor{
373 373
 		Value:          "CANTUNPAUSE",
374 374
 		Message:        "Cannot unpause container %s: %s",
375
+		Description:    "An error occurred while trying to unpause the specified container",
375 376
 		HTTPStatusCode: http.StatusInternalServerError,
376 377
 	})
377 378
 
... ...
@@ -379,6 +424,7 @@ var (
379 379
 	ErrorCodePSError = errcode.Register(errGroup, errcode.ErrorDescriptor{
380 380
 		Value:          "PSError",
381 381
 		Message:        "Error running ps: %s",
382
+		Description:    "There was an error trying to run the 'ps' command in the specified container",
382 383
 		HTTPStatusCode: http.StatusInternalServerError,
383 384
 	})
384 385
 
... ...
@@ -387,6 +433,7 @@ var (
387 387
 	ErrorCodeNoPID = errcode.Register(errGroup, errcode.ErrorDescriptor{
388 388
 		Value:          "NOPID",
389 389
 		Message:        "Couldn't find PID field in ps output",
390
+		Description:    "There was no 'PID' field in the output of the 'ps' command that was executed",
390 391
 		HTTPStatusCode: http.StatusInternalServerError,
391 392
 	})
392 393
 
... ...
@@ -394,6 +441,7 @@ var (
394 394
 	ErrorCodeBadPID = errcode.Register(errGroup, errcode.ErrorDescriptor{
395 395
 		Value:          "BADPID",
396 396
 		Message:        "Unexpected pid '%s': %s",
397
+		Description:    "While trying to parse the output of the 'ps' command, the 'PID' field was not an integer",
397 398
 		HTTPStatusCode: http.StatusInternalServerError,
398 399
 	})
399 400
 
... ...
@@ -402,6 +450,7 @@ var (
402 402
 	ErrorCodeNoTop = errcode.Register(errGroup, errcode.ErrorDescriptor{
403 403
 		Value:          "NOTOP",
404 404
 		Message:        "Top is not supported on Windows",
405
+		Description:    "The 'top' command is not supported on Windows",
405 406
 		HTTPStatusCode: http.StatusInternalServerError,
406 407
 	})
407 408
 
... ...
@@ -410,6 +459,7 @@ var (
410 410
 	ErrorCodeStopped = errcode.Register(errGroup, errcode.ErrorDescriptor{
411 411
 		Value:          "STOPPED",
412 412
 		Message:        "Container already stopped",
413
+		Description:    "An attempt was made to stop a container, but the container is already stopped",
413 414
 		HTTPStatusCode: http.StatusNotModified,
414 415
 	})
415 416
 
... ...
@@ -418,14 +468,16 @@ var (
418 418
 	ErrorCodeCantStop = errcode.Register(errGroup, errcode.ErrorDescriptor{
419 419
 		Value:          "CANTSTOP",
420 420
 		Message:        "Cannot stop container %s: %s\n",
421
+		Description:    "An error occurred while tring to stop the specified container",
421 422
 		HTTPStatusCode: http.StatusInternalServerError,
422 423
 	})
423 424
 
424
-	// ErrorCodeBadCPUFields is generated the number of CPU fields is
425
+	// ErrorCodeBadCPUFields is generated when the number of CPU fields is
425 426
 	// less than 8.
426 427
 	ErrorCodeBadCPUFields = errcode.Register(errGroup, errcode.ErrorDescriptor{
427 428
 		Value:          "BADCPUFIELDS",
428 429
 		Message:        "invalid number of cpu fields",
430
+		Description:    "While reading the '/proc/stat' file, the number of 'cpu' fields is less than 8",
429 431
 		HTTPStatusCode: http.StatusInternalServerError,
430 432
 	})
431 433
 
... ...
@@ -433,6 +485,7 @@ var (
433 433
 	ErrorCodeBadCPUInt = errcode.Register(errGroup, errcode.ErrorDescriptor{
434 434
 		Value:          "BADCPUINT",
435 435
 		Message:        "Unable to convert value %s to int: %s",
436
+		Description:    "While reading the '/proc/stat' file, the 'CPU' field could not be parsed as an integer",
436 437
 		HTTPStatusCode: http.StatusInternalServerError,
437 438
 	})
438 439
 
... ...
@@ -441,6 +494,7 @@ var (
441 441
 	ErrorCodeBadStatFormat = errcode.Register(errGroup, errcode.ErrorDescriptor{
442 442
 		Value:          "BADSTATFORMAT",
443 443
 		Message:        "invalid stat format",
444
+		Description:    "There was an error trying to parse the '/proc/stat' file",
444 445
 		HTTPStatusCode: http.StatusInternalServerError,
445 446
 	})
446 447
 
... ...
@@ -448,6 +502,7 @@ var (
448 448
 	ErrorCodeTimedOut = errcode.Register(errGroup, errcode.ErrorDescriptor{
449 449
 		Value:          "TIMEDOUT",
450 450
 		Message:        "Timed out: %v",
451
+		Description:    "A timer expired",
451 452
 		HTTPStatusCode: http.StatusInternalServerError,
452 453
 	})
453 454
 
... ...
@@ -456,6 +511,7 @@ var (
456 456
 	ErrorCodeAlreadyRemoving = errcode.Register(errGroup, errcode.ErrorDescriptor{
457 457
 		Value:          "ALREADYREMOVING",
458 458
 		Message:        "Status is already RemovalInProgress",
459
+		Description:    "An attempt to remove a container was made, but the container is already in the process of being removed",
459 460
 		HTTPStatusCode: http.StatusInternalServerError,
460 461
 	})
461 462
 
... ...
@@ -463,6 +519,7 @@ var (
463 463
 	ErrorCodeStartPaused = errcode.Register(errGroup, errcode.ErrorDescriptor{
464 464
 		Value:          "STARTPAUSED",
465 465
 		Message:        "Cannot start a paused container, try unpause instead.",
466
+		Description:    "An attempt to start a container was made, but the container is paused. Unpause it first",
466 467
 		HTTPStatusCode: http.StatusInternalServerError,
467 468
 	})
468 469
 
... ...
@@ -471,6 +528,7 @@ var (
471 471
 	ErrorCodeAlreadyStarted = errcode.Register(errGroup, errcode.ErrorDescriptor{
472 472
 		Value:          "ALREADYSTARTED",
473 473
 		Message:        "Container already started",
474
+		Description:    "An attempt to start a container was made, but the container is already started",
474 475
 		HTTPStatusCode: http.StatusNotModified,
475 476
 	})
476 477
 
... ...
@@ -479,6 +537,7 @@ var (
479 479
 	ErrorCodeHostConfigStart = errcode.Register(errGroup, errcode.ErrorDescriptor{
480 480
 		Value:          "HOSTCONFIGSTART",
481 481
 		Message:        "Supplying a hostconfig on start is not supported. It should be supplied on create",
482
+		Description:    "The 'start' command does not accept 'HostConfig' data, try using the 'create' command instead",
482 483
 		HTTPStatusCode: http.StatusInternalServerError,
483 484
 	})
484 485
 
... ...
@@ -487,6 +546,285 @@ var (
487 487
 	ErrorCodeCantStart = errcode.Register(errGroup, errcode.ErrorDescriptor{
488 488
 		Value:          "CANTSTART",
489 489
 		Message:        "Cannot start container %s: %s",
490
+		Description:    "There was an error while trying to start a container",
491
+		HTTPStatusCode: http.StatusInternalServerError,
492
+	})
493
+
494
+	// ErrorCodeCantRestart is generated when an error occurred while
495
+	// trying to restart a container.
496
+	ErrorCodeCantRestart = errcode.Register(errGroup, errcode.ErrorDescriptor{
497
+		Value:          "CANTRESTART",
498
+		Message:        "Cannot restart container %s: %s",
499
+		Description:    "There was an error while trying to restart a container",
500
+		HTTPStatusCode: http.StatusInternalServerError,
501
+	})
502
+
503
+	// ErrorCodeEmptyRename is generated when one of the names on a
504
+	// rename is empty.
505
+	ErrorCodeEmptyRename = errcode.Register(errGroup, errcode.ErrorDescriptor{
506
+		Value:          "EMPTYRENAME",
507
+		Message:        "Neither old nor new names may be empty",
508
+		Description:    "An attempt was made to rename a container but either the old or new names were blank",
509
+		HTTPStatusCode: http.StatusInternalServerError,
510
+	})
511
+
512
+	// ErrorCodeRenameTaken is generated when we try to rename but the
513
+	// new name isn't available.
514
+	ErrorCodeRenameTaken = errcode.Register(errGroup, errcode.ErrorDescriptor{
515
+		Value:          "RENAMETAKEN",
516
+		Message:        "Error when allocating new name: %s",
517
+		Description:    "The new name specified on the 'rename' command is already being used",
518
+		HTTPStatusCode: http.StatusInternalServerError,
519
+	})
520
+
521
+	// ErrorCodeRenameDelete is generated when we try to rename but
522
+	// failed trying to delete the old container.
523
+	ErrorCodeRenameDelete = errcode.Register(errGroup, errcode.ErrorDescriptor{
524
+		Value:          "RENAMEDELETE",
525
+		Message:        "Failed to delete container %q: %v",
526
+		Description:    "There was an error trying to delete the specified container",
527
+		HTTPStatusCode: http.StatusInternalServerError,
528
+	})
529
+
530
+	// ErrorCodePauseError is generated when we try to pause a container
531
+	// but failed.
532
+	ErrorCodePauseError = errcode.Register(errGroup, errcode.ErrorDescriptor{
533
+		Value:          "PAUSEERROR",
534
+		Message:        "Cannot pause container %s: %s",
535
+		Description:    "There was an error trying to pause the specified container",
536
+		HTTPStatusCode: http.StatusInternalServerError,
537
+	})
538
+
539
+	// ErrorCodeNeedStream is generated when we try to stream a container's
540
+	// logs but no output stream was specified.
541
+	ErrorCodeNeedStream = errcode.Register(errGroup, errcode.ErrorDescriptor{
542
+		Value:          "NEEDSTREAM",
543
+		Message:        "You must choose at least one stream",
544
+		Description:    "While trying to stream a container's logs, no output stream was specified",
545
+		HTTPStatusCode: http.StatusInternalServerError,
546
+	})
547
+
548
+	// ErrorCodeDanglingOne is generated when we try to specify more than one
549
+	// 'dangling' specifier.
550
+	ErrorCodeDanglingOne = errcode.Register(errGroup, errcode.ErrorDescriptor{
551
+		Value:          "DANLGINGONE",
552
+		Message:        "Conflict: cannot use more than 1 value for `dangling` filter",
553
+		Description:    "The specified 'dangling' filter may not have more than one value",
554
+		HTTPStatusCode: http.StatusConflict,
555
+	})
556
+
557
+	// ErrorCodeImgDelUsed is generated when we try to delete an image
558
+	// but it is being used.
559
+	ErrorCodeImgDelUsed = errcode.Register(errGroup, errcode.ErrorDescriptor{
560
+		Value:          "IMGDELUSED",
561
+		Message:        "conflict: unable to remove repository reference %q (must force) - container %s is using its referenced image %s",
562
+		Description:    "An attempt was made to delete an image but it is currently being used",
563
+		HTTPStatusCode: http.StatusConflict,
564
+	})
565
+
566
+	// ErrorCodeImgNoParent is generated when we try to find an image's
567
+	// parent but its not in the graph.
568
+	ErrorCodeImgNoParent = errcode.Register(errGroup, errcode.ErrorDescriptor{
569
+		Value:          "IMGNOPARENT",
570
+		Message:        "unable to get parent image: %v",
571
+		Description:    "There was an error trying to find an image's parent, it was not in the graph",
572
+		HTTPStatusCode: http.StatusInternalServerError,
573
+	})
574
+
575
+	// ErrorCodeExportFailed is generated when an export fails.
576
+	ErrorCodeExportFailed = errcode.Register(errGroup, errcode.ErrorDescriptor{
577
+		Value:          "EXPORTFAILED",
578
+		Message:        "%s: %s",
579
+		Description:    "There was an error during an export operation",
580
+		HTTPStatusCode: http.StatusInternalServerError,
581
+	})
582
+
583
+	// ErrorCodeExecResize is generated when we try to resize an exec
584
+	// but its not running.
585
+	ErrorCodeExecResize = errcode.Register(errGroup, errcode.ErrorDescriptor{
586
+		Value:          "EXECRESIZE",
587
+		Message:        "Exec %s is not running, so it can not be resized.",
588
+		Description:    "An attempt was made to resize an 'exec', but the 'exec' is not running",
589
+		HTTPStatusCode: http.StatusInternalServerError,
590
+	})
591
+
592
+	// ErrorCodeContainerNotRunning is generated when we try to get the info
593
+	// on an exec but the container is not running.
594
+	ErrorCodeContainerNotRunning = errcode.Register(errGroup, errcode.ErrorDescriptor{
595
+		Value:          "CONTAINERNOTRUNNING",
596
+		Message:        "Container %s is not running: %s",
597
+		Description:    "An attempt was made to retrieve the information about an 'exec' but the container is not running",
598
+		HTTPStatusCode: http.StatusInternalServerError,
599
+	})
600
+
601
+	// ErrorCodeNoExecID is generated when we try to get the info
602
+	// on an exec but it can't be found.
603
+	ErrorCodeNoExecID = errcode.Register(errGroup, errcode.ErrorDescriptor{
604
+		Value:          "NOEXECID",
605
+		Message:        "No such exec instance '%s' found in daemon",
606
+		Description:    "The specified 'exec' instance could not be found",
607
+		HTTPStatusCode: http.StatusNotFound,
608
+	})
609
+
610
+	// ErrorCodeExecPaused is generated when we try to start an exec
611
+	// but the container is paused.
612
+	ErrorCodeExecPaused = errcode.Register(errGroup, errcode.ErrorDescriptor{
613
+		Value:          "EXECPAUSED",
614
+		Message:        "Container %s is paused, unpause the container before exec",
615
+		Description:    "An attempt to start an 'exec' was made, but the owning container is paused",
616
+		HTTPStatusCode: http.StatusInternalServerError,
617
+	})
618
+
619
+	// ErrorCodeExecRunning is generated when we try to start an exec
620
+	// but its already running.
621
+	ErrorCodeExecRunning = errcode.Register(errGroup, errcode.ErrorDescriptor{
622
+		Value:          "EXECRUNNING",
623
+		Message:        "Error: Exec command %s is already running",
624
+		Description:    "An attempt to start an 'exec' was made, but 'exec' is already running",
625
+		HTTPStatusCode: http.StatusInternalServerError,
626
+	})
627
+
628
+	// ErrorCodeExecCantRun is generated when we try to start an exec
629
+	// but it failed for some reason.
630
+	ErrorCodeExecCantRun = errcode.Register(errGroup, errcode.ErrorDescriptor{
631
+		Value:          "EXECCANTRUN",
632
+		Message:        "Cannot run exec command %s in container %s: %s",
633
+		Description:    "An attempt to start an 'exec' was made, but an error occurred",
634
+		HTTPStatusCode: http.StatusInternalServerError,
635
+	})
636
+
637
+	// ErrorCodeExecAttach is generated when we try to attach to an exec
638
+	// but failed.
639
+	ErrorCodeExecAttach = errcode.Register(errGroup, errcode.ErrorDescriptor{
640
+		Value:          "EXECATTACH",
641
+		Message:        "attach failed with error: %s",
642
+		Description:    "There was an error while trying to attach to an 'exec'",
643
+		HTTPStatusCode: http.StatusInternalServerError,
644
+	})
645
+
646
+	// ErrorCodeExecContainerStopped is generated when we try to start
647
+	// an exec but then the container stopped.
648
+	ErrorCodeExecContainerStopped = errcode.Register(errGroup, errcode.ErrorDescriptor{
649
+		Value:          "EXECCONTAINERSTOPPED",
650
+		Message:        "container stopped while running exec",
651
+		Description:    "An attempt was made to start an 'exec' but the owning container is in the 'stopped' state",
652
+		HTTPStatusCode: http.StatusInternalServerError,
653
+	})
654
+
655
+	// ErrorCodeDefaultName is generated when we try to delete the
656
+	// default name of a container.
657
+	ErrorCodeDefaultName = errcode.Register(errGroup, errcode.ErrorDescriptor{
658
+		Value:          "DEFAULTNAME",
659
+		Message:        "Conflict, cannot remove the default name of the container",
660
+		Description:    "An attempt to delete the default name of a container was made, but that is not allowed",
661
+		HTTPStatusCode: http.StatusConflict,
662
+	})
663
+
664
+	// ErrorCodeNoParent is generated when we try to delete a container
665
+	// but we can't find its parent image.
666
+	ErrorCodeNoParent = errcode.Register(errGroup, errcode.ErrorDescriptor{
667
+		Value:          "NOPARENT",
668
+		Message:        "Cannot get parent %s for name %s",
669
+		Description:    "An attempt was made to delete a container but its parent image could not be found",
670
+		HTTPStatusCode: http.StatusInternalServerError,
671
+	})
672
+
673
+	// ErrorCodeCantDestroy is generated when we try to delete a container
674
+	// but failed for some reason.
675
+	ErrorCodeCantDestroy = errcode.Register(errGroup, errcode.ErrorDescriptor{
676
+		Value:          "CANTDESTROY",
677
+		Message:        "Cannot destroy container %s: %v",
678
+		Description:    "An attempt was made to delete a container but it failed",
679
+		HTTPStatusCode: http.StatusInternalServerError,
680
+	})
681
+
682
+	// ErrorCodeRmRunning is generated when we try to delete a container
683
+	// but its still running.
684
+	ErrorCodeRmRunning = errcode.Register(errGroup, errcode.ErrorDescriptor{
685
+		Value:          "RMRUNNING",
686
+		Message:        "Conflict, You cannot remove a running container. Stop the container before attempting removal or use -f",
687
+		Description:    "An attempt was made to delete a container but the container is still running, try to either stop it first or use '-f'",
688
+		HTTPStatusCode: http.StatusConflict,
689
+	})
690
+
691
+	// ErrorCodeRmFailed is generated when we try to delete a container
692
+	// but it failed for some reason.
693
+	ErrorCodeRmFailed = errcode.Register(errGroup, errcode.ErrorDescriptor{
694
+		Value:          "RMFAILED",
695
+		Message:        "Could not kill running container, cannot remove - %v",
696
+		Description:    "An error occurred while trying to delete a running container",
697
+		HTTPStatusCode: http.StatusInternalServerError,
698
+	})
699
+
700
+	// ErrorCodeRmNotFound is generated when we try to delete a container
701
+	// but couldn't find it.
702
+	ErrorCodeRmNotFound = errcode.Register(errGroup, errcode.ErrorDescriptor{
703
+		Value:          "RMNOTFOUND",
704
+		Message:        "Could not kill running container, cannot remove - %v",
705
+		Description:    "An attempt to delete a container was made but the container could not be found",
706
+		HTTPStatusCode: http.StatusInternalServerError,
707
+	})
708
+
709
+	// ErrorCodeRmState is generated when we try to delete a container
710
+	// but couldn't set its state to RemovalInProgress.
711
+	ErrorCodeRmState = errcode.Register(errGroup, errcode.ErrorDescriptor{
712
+		Value:          "RMSTATE",
713
+		Message:        "Failed to set container state to RemovalInProgress: %s",
714
+		Description:    "An attempt to delete a container was made, but there as an error trying to set its state to 'RemovalInProgress'",
715
+		HTTPStatusCode: http.StatusInternalServerError,
716
+	})
717
+
718
+	// ErrorCodeRmDriverFS is generated when we try to delete a container
719
+	// but the driver failed to delete its filesystem.
720
+	ErrorCodeRmDriverFS = errcode.Register(errGroup, errcode.ErrorDescriptor{
721
+		Value:          "RMDRIVERFS",
722
+		Message:        "Driver %s failed to remove root filesystem %s: %s",
723
+		Description:    "While trying to delete a container, the driver failed to remove the root filesystem",
724
+		HTTPStatusCode: http.StatusInternalServerError,
725
+	})
726
+
727
+	// ErrorCodeRmInit is generated when we try to delete a container
728
+	// but failed deleting its init filesystem.
729
+	ErrorCodeRmInit = errcode.Register(errGroup, errcode.ErrorDescriptor{
730
+		Value:          "RMINIT",
731
+		Message:        "Driver %s failed to remove init filesystem %s: %s",
732
+		Description:    "While trying to delete a container, the driver failed to remove the init filesystem",
733
+		HTTPStatusCode: http.StatusInternalServerError,
734
+	})
735
+
736
+	// ErrorCodeRmFS is generated when we try to delete a container
737
+	// but failed deleting its filesystem.
738
+	ErrorCodeRmFS = errcode.Register(errGroup, errcode.ErrorDescriptor{
739
+		Value:          "RMFS",
740
+		Message:        "Unable to remove filesystem for %v: %v",
741
+		Description:    "While trying to delete a container, the driver failed to remove the filesystem",
742
+		HTTPStatusCode: http.StatusInternalServerError,
743
+	})
744
+
745
+	// ErrorCodeRmExecDriver is generated when we try to delete a container
746
+	// but failed deleting its exec driver data.
747
+	ErrorCodeRmExecDriver = errcode.Register(errGroup, errcode.ErrorDescriptor{
748
+		Value:          "RMEXECDRIVER",
749
+		Message:        "Unable to remove execdriver data for %s: %s",
750
+		Description:    "While trying to delete a container, there was an error trying to remove th exec driver data",
751
+		HTTPStatusCode: http.StatusInternalServerError,
752
+	})
753
+
754
+	// ErrorCodeRmVolumeInUse is generated when we try to delete a container
755
+	// but failed deleting a volume because its being used.
756
+	ErrorCodeRmVolumeInUse = errcode.Register(errGroup, errcode.ErrorDescriptor{
757
+		Value:          "RMVOLUMEINUSE",
758
+		Message:        "Conflict: %v",
759
+		Description:    "While trying to delete a container, one of its volumes is still being used",
760
+		HTTPStatusCode: http.StatusConflict,
761
+	})
762
+
763
+	// ErrorCodeRmVolume is generated when we try to delete a container
764
+	// but failed deleting a volume.
765
+	ErrorCodeRmVolume = errcode.Register(errGroup, errcode.ErrorDescriptor{
766
+		Value:          "RMVOLUME",
767
+		Message:        "Error while removing volume %s: %v",
768
+		Description:    "While trying to delete a container, there was an error trying to delete one of its volumes",
490 769
 		HTTPStatusCode: http.StatusInternalServerError,
491 770
 	})
492 771
 )