- Make the API client library completely standalone.
- Move windows partition isolation detection to the client, so the
driver doesn't use external types.
Signed-off-by: David Calavera <david.calavera@gmail.com>
| ... | ... |
@@ -9,9 +9,9 @@ import ( |
| 9 | 9 |
|
| 10 | 10 |
"github.com/docker/docker/api/client/lib" |
| 11 | 11 |
"github.com/docker/docker/api/types" |
| 12 |
+ "github.com/docker/docker/api/types/container" |
|
| 12 | 13 |
"github.com/docker/docker/api/types/filters" |
| 13 | 14 |
"github.com/docker/docker/api/types/registry" |
| 14 |
- "github.com/docker/docker/runconfig" |
|
| 15 | 15 |
) |
| 16 | 16 |
|
| 17 | 17 |
// apiClient is an interface that clients that talk with a docker server must implement. |
| ... | ... |
@@ -19,7 +19,7 @@ type apiClient interface {
|
| 19 | 19 |
ClientVersion() string |
| 20 | 20 |
ContainerAttach(options types.ContainerAttachOptions) (types.HijackedResponse, error) |
| 21 | 21 |
ContainerCommit(options types.ContainerCommitOptions) (types.ContainerCommitResponse, error) |
| 22 |
- ContainerCreate(config *runconfig.ContainerConfigWrapper, containerName string) (types.ContainerCreateResponse, error) |
|
| 22 |
+ ContainerCreate(config *container.Config, hostConfig *container.HostConfig, containerName string) (types.ContainerCreateResponse, error) |
|
| 23 | 23 |
ContainerDiff(containerID string) ([]types.ContainerChange, error) |
| 24 | 24 |
ContainerExecAttach(execID string, config types.ExecConfig) (types.HijackedResponse, error) |
| 25 | 25 |
ContainerExecCreate(config types.ExecConfig) (types.ContainerExecCreateResponse, error) |
| ... | ... |
@@ -6,11 +6,11 @@ import ( |
| 6 | 6 |
"fmt" |
| 7 | 7 |
|
| 8 | 8 |
"github.com/docker/docker/api/types" |
| 9 |
+ "github.com/docker/docker/api/types/container" |
|
| 9 | 10 |
Cli "github.com/docker/docker/cli" |
| 10 | 11 |
"github.com/docker/docker/opts" |
| 11 | 12 |
flag "github.com/docker/docker/pkg/mflag" |
| 12 | 13 |
"github.com/docker/docker/reference" |
| 13 |
- "github.com/docker/docker/runconfig" |
|
| 14 | 14 |
) |
| 15 | 15 |
|
| 16 | 16 |
// CmdCommit creates a new image from a container's changes. |
| ... | ... |
@@ -54,9 +54,9 @@ func (cli *DockerCli) CmdCommit(args ...string) error {
|
| 54 | 54 |
} |
| 55 | 55 |
} |
| 56 | 56 |
|
| 57 |
- var config *runconfig.Config |
|
| 57 |
+ var config *container.Config |
|
| 58 | 58 |
if *flConfig != "" {
|
| 59 |
- config = &runconfig.Config{}
|
|
| 59 |
+ config = &container.Config{}
|
|
| 60 | 60 |
if err := json.Unmarshal([]byte(*flConfig), config); err != nil {
|
| 61 | 61 |
return err |
| 62 | 62 |
} |
| ... | ... |
@@ -7,6 +7,7 @@ import ( |
| 7 | 7 |
|
| 8 | 8 |
"github.com/docker/docker/api/client/lib" |
| 9 | 9 |
"github.com/docker/docker/api/types" |
| 10 |
+ "github.com/docker/docker/api/types/container" |
|
| 10 | 11 |
Cli "github.com/docker/docker/cli" |
| 11 | 12 |
"github.com/docker/docker/pkg/jsonmessage" |
| 12 | 13 |
"github.com/docker/docker/reference" |
| ... | ... |
@@ -78,9 +79,7 @@ func newCIDFile(path string) (*cidFile, error) {
|
| 78 | 78 |
return &cidFile{path: path, file: f}, nil
|
| 79 | 79 |
} |
| 80 | 80 |
|
| 81 |
-func (cli *DockerCli) createContainer(config *runconfig.Config, hostConfig *runconfig.HostConfig, cidfile, name string) (*types.ContainerCreateResponse, error) {
|
|
| 82 |
- mergedConfig := runconfig.MergeConfigs(config, hostConfig) |
|
| 83 |
- |
|
| 81 |
+func (cli *DockerCli) createContainer(config *container.Config, hostConfig *container.HostConfig, cidfile, name string) (*types.ContainerCreateResponse, error) {
|
|
| 84 | 82 |
var containerIDFile *cidFile |
| 85 | 83 |
if cidfile != "" {
|
| 86 | 84 |
var err error |
| ... | ... |
@@ -108,7 +107,7 @@ func (cli *DockerCli) createContainer(config *runconfig.Config, hostConfig *runc |
| 108 | 108 |
} |
| 109 | 109 |
|
| 110 | 110 |
//create the container |
| 111 |
- response, err := cli.client.ContainerCreate(mergedConfig, name) |
|
| 111 |
+ response, err := cli.client.ContainerCreate(config, hostConfig, name) |
|
| 112 | 112 |
//if image not found try to pull it |
| 113 | 113 |
if err != nil {
|
| 114 | 114 |
if lib.IsErrImageNotFound(err) {
|
| ... | ... |
@@ -125,7 +124,7 @@ func (cli *DockerCli) createContainer(config *runconfig.Config, hostConfig *runc |
| 125 | 125 |
} |
| 126 | 126 |
// Retry |
| 127 | 127 |
var retryErr error |
| 128 |
- response, retryErr = cli.client.ContainerCreate(mergedConfig, name) |
|
| 128 |
+ response, retryErr = cli.client.ContainerCreate(config, hostConfig, name) |
|
| 129 | 129 |
if retryErr != nil {
|
| 130 | 130 |
return nil, retryErr |
| 131 | 131 |
} |
| ... | ... |
@@ -6,19 +6,29 @@ import ( |
| 6 | 6 |
"strings" |
| 7 | 7 |
|
| 8 | 8 |
"github.com/docker/docker/api/types" |
| 9 |
- "github.com/docker/docker/runconfig" |
|
| 9 |
+ "github.com/docker/docker/api/types/container" |
|
| 10 | 10 |
) |
| 11 | 11 |
|
| 12 |
+type configWrapper struct {
|
|
| 13 |
+ *container.Config |
|
| 14 |
+ HostConfig *container.HostConfig |
|
| 15 |
+} |
|
| 16 |
+ |
|
| 12 | 17 |
// ContainerCreate creates a new container based in the given configuration. |
| 13 | 18 |
// It can be associated with a name, but it's not mandatory. |
| 14 |
-func (cli *Client) ContainerCreate(config *runconfig.ContainerConfigWrapper, containerName string) (types.ContainerCreateResponse, error) {
|
|
| 19 |
+func (cli *Client) ContainerCreate(config *container.Config, hostConfig *container.HostConfig, containerName string) (types.ContainerCreateResponse, error) {
|
|
| 15 | 20 |
var response types.ContainerCreateResponse |
| 16 | 21 |
query := url.Values{}
|
| 17 | 22 |
if containerName != "" {
|
| 18 | 23 |
query.Set("name", containerName)
|
| 19 | 24 |
} |
| 20 | 25 |
|
| 21 |
- serverResp, err := cli.post("/containers/create", query, config, nil)
|
|
| 26 |
+ body := configWrapper{
|
|
| 27 |
+ Config: config, |
|
| 28 |
+ HostConfig: hostConfig, |
|
| 29 |
+ } |
|
| 30 |
+ |
|
| 31 |
+ serverResp, err := cli.post("/containers/create", query, body, nil)
|
|
| 22 | 32 |
if err != nil {
|
| 23 | 33 |
if serverResp != nil && serverResp.statusCode == 404 && strings.Contains(err.Error(), config.Image) {
|
| 24 | 34 |
return response, imageNotFoundError{config.Image}
|
| ... | ... |
@@ -10,7 +10,7 @@ import ( |
| 10 | 10 |
"strings" |
| 11 | 11 |
|
| 12 | 12 |
"github.com/docker/docker/api/types" |
| 13 |
- "github.com/docker/docker/runconfig" |
|
| 13 |
+ "github.com/docker/docker/api/types/container" |
|
| 14 | 14 |
"github.com/docker/go-units" |
| 15 | 15 |
) |
| 16 | 16 |
|
| ... | ... |
@@ -73,7 +73,7 @@ func imageBuildOptionsToQuery(options types.ImageBuildOptions) (url.Values, erro |
| 73 | 73 |
query.Set("pull", "1")
|
| 74 | 74 |
} |
| 75 | 75 |
|
| 76 |
- if !runconfig.IsolationLevel.IsDefault(runconfig.IsolationLevel(options.Isolation)) {
|
|
| 76 |
+ if !container.IsolationLevel.IsDefault(container.IsolationLevel(options.Isolation)) {
|
|
| 77 | 77 |
query.Set("isolation", options.Isolation)
|
| 78 | 78 |
} |
| 79 | 79 |
|
| ... | ... |
@@ -14,6 +14,7 @@ import ( |
| 14 | 14 |
"github.com/Sirupsen/logrus" |
| 15 | 15 |
"github.com/docker/docker/api/server/httputils" |
| 16 | 16 |
"github.com/docker/docker/api/types" |
| 17 |
+ "github.com/docker/docker/api/types/container" |
|
| 17 | 18 |
"github.com/docker/docker/builder" |
| 18 | 19 |
"github.com/docker/docker/builder/dockerfile" |
| 19 | 20 |
"github.com/docker/docker/daemon/daemonbuilder" |
| ... | ... |
@@ -24,7 +25,6 @@ import ( |
| 24 | 24 |
"github.com/docker/docker/pkg/streamformatter" |
| 25 | 25 |
"github.com/docker/docker/pkg/ulimit" |
| 26 | 26 |
"github.com/docker/docker/reference" |
| 27 |
- "github.com/docker/docker/runconfig" |
|
| 28 | 27 |
"github.com/docker/docker/utils" |
| 29 | 28 |
"golang.org/x/net/context" |
| 30 | 29 |
) |
| ... | ... |
@@ -144,8 +144,8 @@ func (br *buildRouter) postBuild(ctx context.Context, w http.ResponseWriter, r * |
| 144 | 144 |
buildConfig.ShmSize = &shmSize |
| 145 | 145 |
} |
| 146 | 146 |
|
| 147 |
- if i := runconfig.IsolationLevel(r.FormValue("isolation")); i != "" {
|
|
| 148 |
- if !runconfig.IsolationLevel.IsValid(i) {
|
|
| 147 |
+ if i := container.IsolationLevel(r.FormValue("isolation")); i != "" {
|
|
| 148 |
+ if !container.IsolationLevel.IsValid(i) {
|
|
| 149 | 149 |
return errf(fmt.Errorf("Unsupported isolation: %q", i))
|
| 150 | 150 |
} |
| 151 | 151 |
buildConfig.Isolation = i |
| ... | ... |
@@ -5,11 +5,11 @@ import ( |
| 5 | 5 |
"time" |
| 6 | 6 |
|
| 7 | 7 |
"github.com/docker/docker/api/types" |
| 8 |
+ "github.com/docker/docker/api/types/container" |
|
| 8 | 9 |
"github.com/docker/docker/daemon" |
| 9 | 10 |
"github.com/docker/docker/daemon/exec" |
| 10 | 11 |
"github.com/docker/docker/pkg/archive" |
| 11 | 12 |
"github.com/docker/docker/pkg/version" |
| 12 |
- "github.com/docker/docker/runconfig" |
|
| 13 | 13 |
) |
| 14 | 14 |
|
| 15 | 15 |
// execBackend includes functions to implement to provide exec functionality. |
| ... | ... |
@@ -39,7 +39,7 @@ type stateBackend interface {
|
| 39 | 39 |
ContainerResize(name string, height, width int) error |
| 40 | 40 |
ContainerRestart(name string, seconds int) error |
| 41 | 41 |
ContainerRm(name string, config *types.ContainerRmConfig) error |
| 42 |
- ContainerStart(name string, hostConfig *runconfig.HostConfig) error |
|
| 42 |
+ ContainerStart(name string, hostConfig *container.HostConfig) error |
|
| 43 | 43 |
ContainerStop(name string, seconds int) error |
| 44 | 44 |
ContainerUnpause(name string) error |
| 45 | 45 |
ContainerWait(name string, timeout time.Duration) (int, error) |
| ... | ... |
@@ -13,6 +13,7 @@ import ( |
| 13 | 13 |
"github.com/docker/distribution/registry/api/errcode" |
| 14 | 14 |
"github.com/docker/docker/api/server/httputils" |
| 15 | 15 |
"github.com/docker/docker/api/types" |
| 16 |
+ "github.com/docker/docker/api/types/container" |
|
| 16 | 17 |
timetypes "github.com/docker/docker/api/types/time" |
| 17 | 18 |
"github.com/docker/docker/daemon" |
| 18 | 19 |
derr "github.com/docker/docker/errors" |
| ... | ... |
@@ -162,7 +163,7 @@ func (s *containerRouter) postContainersStart(ctx context.Context, w http.Respon |
| 162 | 162 |
// net/http otherwise seems to swallow any headers related to chunked encoding |
| 163 | 163 |
// including r.TransferEncoding |
| 164 | 164 |
// allow a nil body for backwards compatibility |
| 165 |
- var hostConfig *runconfig.HostConfig |
|
| 165 |
+ var hostConfig *container.HostConfig |
|
| 166 | 166 |
if r.Body != nil && (r.ContentLength > 0 || r.ContentLength == -1) {
|
| 167 | 167 |
if err := httputils.CheckForJSON(r); err != nil {
|
| 168 | 168 |
return err |
| ... | ... |
@@ -12,6 +12,7 @@ import ( |
| 12 | 12 |
"github.com/docker/distribution/digest" |
| 13 | 13 |
"github.com/docker/docker/api/server/httputils" |
| 14 | 14 |
"github.com/docker/docker/api/types" |
| 15 |
+ "github.com/docker/docker/api/types/container" |
|
| 15 | 16 |
"github.com/docker/docker/builder/dockerfile" |
| 16 | 17 |
derr "github.com/docker/docker/errors" |
| 17 | 18 |
"github.com/docker/docker/pkg/ioutils" |
| ... | ... |
@@ -43,7 +44,7 @@ func (s *router) postCommit(ctx context.Context, w http.ResponseWriter, r *http. |
| 43 | 43 |
return err |
| 44 | 44 |
} |
| 45 | 45 |
if c == nil {
|
| 46 |
- c = &runconfig.Config{}
|
|
| 46 |
+ c = &container.Config{}
|
|
| 47 | 47 |
} |
| 48 | 48 |
|
| 49 | 49 |
if !s.daemon.Exists(cname) {
|
| ... | ... |
@@ -162,8 +163,8 @@ func (s *router) postImagesCreate(ctx context.Context, w http.ResponseWriter, r |
| 162 | 162 |
// 'err' MUST NOT be defined within this block, we need any error |
| 163 | 163 |
// generated from the download to be available to the output |
| 164 | 164 |
// stream processing below |
| 165 |
- var newConfig *runconfig.Config |
|
| 166 |
- newConfig, err = dockerfile.BuildFromConfig(&runconfig.Config{}, r.Form["changes"])
|
|
| 165 |
+ var newConfig *container.Config |
|
| 166 |
+ newConfig, err = dockerfile.BuildFromConfig(&container.Config{}, r.Form["changes"])
|
|
| 167 | 167 |
if err != nil {
|
| 168 | 168 |
return err |
| 169 | 169 |
} |
| ... | ... |
@@ -5,9 +5,9 @@ import ( |
| 5 | 5 |
"io" |
| 6 | 6 |
"net" |
| 7 | 7 |
|
| 8 |
+ "github.com/docker/docker/api/types/container" |
|
| 8 | 9 |
"github.com/docker/docker/api/types/filters" |
| 9 | 10 |
"github.com/docker/docker/pkg/ulimit" |
| 10 |
- "github.com/docker/docker/runconfig" |
|
| 11 | 11 |
) |
| 12 | 12 |
|
| 13 | 13 |
// ContainerAttachOptions holds parameters to attach to a container. |
| ... | ... |
@@ -28,7 +28,7 @@ type ContainerCommitOptions struct {
|
| 28 | 28 |
Author string |
| 29 | 29 |
Changes []string |
| 30 | 30 |
Pause bool |
| 31 |
- Config *runconfig.Config |
|
| 31 |
+ Config *container.Config |
|
| 32 | 32 |
} |
| 33 | 33 |
|
| 34 | 34 |
// ContainerExecInspect holds information returned by exec inspect. |
| ... | ... |
@@ -1,18 +1,16 @@ |
| 1 | 1 |
package types |
| 2 | 2 |
|
| 3 |
+import "github.com/docker/docker/api/types/container" |
|
| 4 |
+ |
|
| 3 | 5 |
// configs holds structs used for internal communication between the |
| 4 | 6 |
// frontend (such as an http server) and the backend (such as the |
| 5 | 7 |
// docker daemon). |
| 6 | 8 |
|
| 7 |
-import ( |
|
| 8 |
- "github.com/docker/docker/runconfig" |
|
| 9 |
-) |
|
| 10 |
- |
|
| 11 | 9 |
// ContainerCreateConfig is the parameter set to ContainerCreate() |
| 12 | 10 |
type ContainerCreateConfig struct {
|
| 13 | 11 |
Name string |
| 14 |
- Config *runconfig.Config |
|
| 15 |
- HostConfig *runconfig.HostConfig |
|
| 12 |
+ Config *container.Config |
|
| 13 |
+ HostConfig *container.HostConfig |
|
| 16 | 14 |
AdjustCPUShares bool |
| 17 | 15 |
} |
| 18 | 16 |
|
| ... | ... |
@@ -33,7 +31,7 @@ type ContainerCommitConfig struct {
|
| 33 | 33 |
Comment string |
| 34 | 34 |
// merge container config into commit config before commit |
| 35 | 35 |
MergeConfigs bool |
| 36 |
- Config *runconfig.Config |
|
| 36 |
+ Config *container.Config |
|
| 37 | 37 |
} |
| 38 | 38 |
|
| 39 | 39 |
// ExecConfig is a small subset of the Config struct that hold the configuration |
| 40 | 40 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,38 @@ |
| 0 |
+package container |
|
| 1 |
+ |
|
| 2 |
+import ( |
|
| 3 |
+ "github.com/docker/docker/api/types/strslice" |
|
| 4 |
+ "github.com/docker/go-connections/nat" |
|
| 5 |
+) |
|
| 6 |
+ |
|
| 7 |
+// Config contains the configuration data about a container. |
|
| 8 |
+// It should hold only portable information about the container. |
|
| 9 |
+// Here, "portable" means "independent from the host we are running on". |
|
| 10 |
+// Non-portable information *should* appear in HostConfig. |
|
| 11 |
+// All fields added to this struct must be marked `omitempty` to keep getting |
|
| 12 |
+// predictable hashes from the old `v1Compatibility` configuration. |
|
| 13 |
+type Config struct {
|
|
| 14 |
+ Hostname string // Hostname |
|
| 15 |
+ Domainname string // Domainname |
|
| 16 |
+ User string // User that will run the command(s) inside the container |
|
| 17 |
+ AttachStdin bool // Attach the standard input, makes possible user interaction |
|
| 18 |
+ AttachStdout bool // Attach the standard output |
|
| 19 |
+ AttachStderr bool // Attach the standard error |
|
| 20 |
+ ExposedPorts map[nat.Port]struct{} `json:",omitempty"` // List of exposed ports
|
|
| 21 |
+ PublishService string `json:",omitempty"` // Name of the network service exposed by the container |
|
| 22 |
+ Tty bool // Attach standard streams to a tty, including stdin if it is not closed. |
|
| 23 |
+ OpenStdin bool // Open stdin |
|
| 24 |
+ StdinOnce bool // If true, close stdin after the 1 attached client disconnects. |
|
| 25 |
+ Env []string // List of environment variable to set in the container |
|
| 26 |
+ Cmd *strslice.StrSlice // Command to run when starting the container |
|
| 27 |
+ ArgsEscaped bool `json:",omitempty"` // True if command is already escaped (Windows specific) |
|
| 28 |
+ Image string // Name of the image as it was passed by the operator (eg. could be symbolic) |
|
| 29 |
+ Volumes map[string]struct{} // List of volumes (mounts) used for the container
|
|
| 30 |
+ WorkingDir string // Current directory (PWD) in the command will be launched |
|
| 31 |
+ Entrypoint *strslice.StrSlice // Entrypoint to run when starting the container |
|
| 32 |
+ NetworkDisabled bool `json:",omitempty"` // Is network disabled |
|
| 33 |
+ MacAddress string `json:",omitempty"` // Mac Address of the container |
|
| 34 |
+ OnBuild []string // ONBUILD metadata that were defined on the image Dockerfile |
|
| 35 |
+ Labels map[string]string // List of labels set to this container |
|
| 36 |
+ StopSignal string `json:",omitempty"` // Signal to stop a container |
|
| 37 |
+} |
| 0 | 38 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,228 @@ |
| 0 |
+package container |
|
| 1 |
+ |
|
| 2 |
+import ( |
|
| 3 |
+ "strings" |
|
| 4 |
+ |
|
| 5 |
+ "github.com/docker/docker/api/types/blkiodev" |
|
| 6 |
+ "github.com/docker/docker/api/types/strslice" |
|
| 7 |
+ "github.com/docker/docker/pkg/ulimit" |
|
| 8 |
+ "github.com/docker/go-connections/nat" |
|
| 9 |
+) |
|
| 10 |
+ |
|
| 11 |
+// NetworkMode represents the container network stack. |
|
| 12 |
+type NetworkMode string |
|
| 13 |
+ |
|
| 14 |
+// IsolationLevel represents the isolation level of a container. The supported |
|
| 15 |
+// values are platform specific |
|
| 16 |
+type IsolationLevel string |
|
| 17 |
+ |
|
| 18 |
+// IsDefault indicates the default isolation level of a container. On Linux this |
|
| 19 |
+// is the native driver. On Windows, this is a Windows Server Container. |
|
| 20 |
+func (i IsolationLevel) IsDefault() bool {
|
|
| 21 |
+ return strings.ToLower(string(i)) == "default" || string(i) == "" |
|
| 22 |
+} |
|
| 23 |
+ |
|
| 24 |
+// IpcMode represents the container ipc stack. |
|
| 25 |
+type IpcMode string |
|
| 26 |
+ |
|
| 27 |
+// IsPrivate indicates whether the container uses it's private ipc stack. |
|
| 28 |
+func (n IpcMode) IsPrivate() bool {
|
|
| 29 |
+ return !(n.IsHost() || n.IsContainer()) |
|
| 30 |
+} |
|
| 31 |
+ |
|
| 32 |
+// IsHost indicates whether the container uses the host's ipc stack. |
|
| 33 |
+func (n IpcMode) IsHost() bool {
|
|
| 34 |
+ return n == "host" |
|
| 35 |
+} |
|
| 36 |
+ |
|
| 37 |
+// IsContainer indicates whether the container uses a container's ipc stack. |
|
| 38 |
+func (n IpcMode) IsContainer() bool {
|
|
| 39 |
+ parts := strings.SplitN(string(n), ":", 2) |
|
| 40 |
+ return len(parts) > 1 && parts[0] == "container" |
|
| 41 |
+} |
|
| 42 |
+ |
|
| 43 |
+// Valid indicates whether the ipc stack is valid. |
|
| 44 |
+func (n IpcMode) Valid() bool {
|
|
| 45 |
+ parts := strings.Split(string(n), ":") |
|
| 46 |
+ switch mode := parts[0]; mode {
|
|
| 47 |
+ case "", "host": |
|
| 48 |
+ case "container": |
|
| 49 |
+ if len(parts) != 2 || parts[1] == "" {
|
|
| 50 |
+ return false |
|
| 51 |
+ } |
|
| 52 |
+ default: |
|
| 53 |
+ return false |
|
| 54 |
+ } |
|
| 55 |
+ return true |
|
| 56 |
+} |
|
| 57 |
+ |
|
| 58 |
+// Container returns the name of the container ipc stack is going to be used. |
|
| 59 |
+func (n IpcMode) Container() string {
|
|
| 60 |
+ parts := strings.SplitN(string(n), ":", 2) |
|
| 61 |
+ if len(parts) > 1 {
|
|
| 62 |
+ return parts[1] |
|
| 63 |
+ } |
|
| 64 |
+ return "" |
|
| 65 |
+} |
|
| 66 |
+ |
|
| 67 |
+// UTSMode represents the UTS namespace of the container. |
|
| 68 |
+type UTSMode string |
|
| 69 |
+ |
|
| 70 |
+// IsPrivate indicates whether the container uses it's private UTS namespace. |
|
| 71 |
+func (n UTSMode) IsPrivate() bool {
|
|
| 72 |
+ return !(n.IsHost()) |
|
| 73 |
+} |
|
| 74 |
+ |
|
| 75 |
+// IsHost indicates whether the container uses the host's UTS namespace. |
|
| 76 |
+func (n UTSMode) IsHost() bool {
|
|
| 77 |
+ return n == "host" |
|
| 78 |
+} |
|
| 79 |
+ |
|
| 80 |
+// Valid indicates whether the UTS namespace is valid. |
|
| 81 |
+func (n UTSMode) Valid() bool {
|
|
| 82 |
+ parts := strings.Split(string(n), ":") |
|
| 83 |
+ switch mode := parts[0]; mode {
|
|
| 84 |
+ case "", "host": |
|
| 85 |
+ default: |
|
| 86 |
+ return false |
|
| 87 |
+ } |
|
| 88 |
+ return true |
|
| 89 |
+} |
|
| 90 |
+ |
|
| 91 |
+// PidMode represents the pid stack of the container. |
|
| 92 |
+type PidMode string |
|
| 93 |
+ |
|
| 94 |
+// IsPrivate indicates whether the container uses it's private pid stack. |
|
| 95 |
+func (n PidMode) IsPrivate() bool {
|
|
| 96 |
+ return !(n.IsHost()) |
|
| 97 |
+} |
|
| 98 |
+ |
|
| 99 |
+// IsHost indicates whether the container uses the host's pid stack. |
|
| 100 |
+func (n PidMode) IsHost() bool {
|
|
| 101 |
+ return n == "host" |
|
| 102 |
+} |
|
| 103 |
+ |
|
| 104 |
+// Valid indicates whether the pid stack is valid. |
|
| 105 |
+func (n PidMode) Valid() bool {
|
|
| 106 |
+ parts := strings.Split(string(n), ":") |
|
| 107 |
+ switch mode := parts[0]; mode {
|
|
| 108 |
+ case "", "host": |
|
| 109 |
+ default: |
|
| 110 |
+ return false |
|
| 111 |
+ } |
|
| 112 |
+ return true |
|
| 113 |
+} |
|
| 114 |
+ |
|
| 115 |
+// DeviceMapping represents the device mapping between the host and the container. |
|
| 116 |
+type DeviceMapping struct {
|
|
| 117 |
+ PathOnHost string |
|
| 118 |
+ PathInContainer string |
|
| 119 |
+ CgroupPermissions string |
|
| 120 |
+} |
|
| 121 |
+ |
|
| 122 |
+// RestartPolicy represents the restart policies of the container. |
|
| 123 |
+type RestartPolicy struct {
|
|
| 124 |
+ Name string |
|
| 125 |
+ MaximumRetryCount int |
|
| 126 |
+} |
|
| 127 |
+ |
|
| 128 |
+// IsNone indicates whether the container has the "no" restart policy. |
|
| 129 |
+// This means the container will not automatically restart when exiting. |
|
| 130 |
+func (rp *RestartPolicy) IsNone() bool {
|
|
| 131 |
+ return rp.Name == "no" |
|
| 132 |
+} |
|
| 133 |
+ |
|
| 134 |
+// IsAlways indicates whether the container has the "always" restart policy. |
|
| 135 |
+// This means the container will automatically restart regardless of the exit status. |
|
| 136 |
+func (rp *RestartPolicy) IsAlways() bool {
|
|
| 137 |
+ return rp.Name == "always" |
|
| 138 |
+} |
|
| 139 |
+ |
|
| 140 |
+// IsOnFailure indicates whether the container has the "on-failure" restart policy. |
|
| 141 |
+// This means the contain will automatically restart of exiting with a non-zero exit status. |
|
| 142 |
+func (rp *RestartPolicy) IsOnFailure() bool {
|
|
| 143 |
+ return rp.Name == "on-failure" |
|
| 144 |
+} |
|
| 145 |
+ |
|
| 146 |
+// IsUnlessStopped indicates whether the container has the |
|
| 147 |
+// "unless-stopped" restart policy. This means the container will |
|
| 148 |
+// automatically restart unless user has put it to stopped state. |
|
| 149 |
+func (rp *RestartPolicy) IsUnlessStopped() bool {
|
|
| 150 |
+ return rp.Name == "unless-stopped" |
|
| 151 |
+} |
|
| 152 |
+ |
|
| 153 |
+// LogConfig represents the logging configuration of the container. |
|
| 154 |
+type LogConfig struct {
|
|
| 155 |
+ Type string |
|
| 156 |
+ Config map[string]string |
|
| 157 |
+} |
|
| 158 |
+ |
|
| 159 |
+// Resources contains container's resources (cgroups config, ulimits...) |
|
| 160 |
+type Resources struct {
|
|
| 161 |
+ // Applicable to all platforms |
|
| 162 |
+ CPUShares int64 `json:"CpuShares"` // CPU shares (relative weight vs. other containers) |
|
| 163 |
+ |
|
| 164 |
+ // Applicable to UNIX platforms |
|
| 165 |
+ CgroupParent string // Parent cgroup. |
|
| 166 |
+ BlkioWeight uint16 // Block IO weight (relative weight vs. other containers) |
|
| 167 |
+ BlkioWeightDevice []*blkiodev.WeightDevice |
|
| 168 |
+ BlkioDeviceReadBps []*blkiodev.ThrottleDevice |
|
| 169 |
+ BlkioDeviceWriteBps []*blkiodev.ThrottleDevice |
|
| 170 |
+ BlkioDeviceReadIOps []*blkiodev.ThrottleDevice |
|
| 171 |
+ BlkioDeviceWriteIOps []*blkiodev.ThrottleDevice |
|
| 172 |
+ CPUPeriod int64 `json:"CpuPeriod"` // CPU CFS (Completely Fair Scheduler) period |
|
| 173 |
+ CPUQuota int64 `json:"CpuQuota"` // CPU CFS (Completely Fair Scheduler) quota |
|
| 174 |
+ CpusetCpus string // CpusetCpus 0-2, 0,1 |
|
| 175 |
+ CpusetMems string // CpusetMems 0-2, 0,1 |
|
| 176 |
+ Devices []DeviceMapping // List of devices to map inside the container |
|
| 177 |
+ KernelMemory int64 // Kernel memory limit (in bytes) |
|
| 178 |
+ Memory int64 // Memory limit (in bytes) |
|
| 179 |
+ MemoryReservation int64 // Memory soft limit (in bytes) |
|
| 180 |
+ MemorySwap int64 // Total memory usage (memory + swap); set `-1` to disable swap |
|
| 181 |
+ MemorySwappiness *int64 // Tuning container memory swappiness behaviour |
|
| 182 |
+ OomKillDisable bool // Whether to disable OOM Killer or not |
|
| 183 |
+ Ulimits []*ulimit.Ulimit // List of ulimits to be set in the container |
|
| 184 |
+} |
|
| 185 |
+ |
|
| 186 |
+// HostConfig the non-portable Config structure of a container. |
|
| 187 |
+// Here, "non-portable" means "dependent of the host we are running on". |
|
| 188 |
+// Portable information *should* appear in Config. |
|
| 189 |
+type HostConfig struct {
|
|
| 190 |
+ // Applicable to all platforms |
|
| 191 |
+ Binds []string // List of volume bindings for this container |
|
| 192 |
+ ContainerIDFile string // File (path) where the containerId is written |
|
| 193 |
+ LogConfig LogConfig // Configuration of the logs for this container |
|
| 194 |
+ NetworkMode NetworkMode // Network mode to use for the container |
|
| 195 |
+ PortBindings nat.PortMap // Port mapping between the exposed port (container) and the host |
|
| 196 |
+ RestartPolicy RestartPolicy // Restart policy to be used for the container |
|
| 197 |
+ VolumeDriver string // Name of the volume driver used to mount volumes |
|
| 198 |
+ VolumesFrom []string // List of volumes to take from other container |
|
| 199 |
+ |
|
| 200 |
+ // Applicable to UNIX platforms |
|
| 201 |
+ CapAdd *strslice.StrSlice // List of kernel capabilities to add to the container |
|
| 202 |
+ CapDrop *strslice.StrSlice // List of kernel capabilities to remove from the container |
|
| 203 |
+ DNS []string `json:"Dns"` // List of DNS server to lookup |
|
| 204 |
+ DNSOptions []string `json:"DnsOptions"` // List of DNSOption to look for |
|
| 205 |
+ DNSSearch []string `json:"DnsSearch"` // List of DNSSearch to look for |
|
| 206 |
+ ExtraHosts []string // List of extra hosts |
|
| 207 |
+ GroupAdd []string // List of additional groups that the container process will run as |
|
| 208 |
+ IpcMode IpcMode // IPC namespace to use for the container |
|
| 209 |
+ Links []string // List of links (in the name:alias form) |
|
| 210 |
+ OomScoreAdj int // Container preference for OOM-killing |
|
| 211 |
+ OomKillDisable bool // Whether to disable OOM Killer or not |
|
| 212 |
+ PidMode PidMode // PID namespace to use for the container |
|
| 213 |
+ Privileged bool // Is the container in privileged mode |
|
| 214 |
+ PublishAllPorts bool // Should docker publish all exposed port for the container |
|
| 215 |
+ ReadonlyRootfs bool // Is the container root filesystem in read-only |
|
| 216 |
+ SecurityOpt []string // List of string values to customize labels for MLS systems, such as SELinux. |
|
| 217 |
+ Tmpfs map[string]string `json:",omitempty"` // List of tmpfs (mounts) used for the container |
|
| 218 |
+ UTSMode UTSMode // UTS namespace to use for the container |
|
| 219 |
+ ShmSize *int64 // Total shm memory usage |
|
| 220 |
+ |
|
| 221 |
+ // Applicable to Windows |
|
| 222 |
+ ConsoleSize [2]int // Initial console size |
|
| 223 |
+ Isolation IsolationLevel // Isolation level of the container (eg default, hyperv) |
|
| 224 |
+ |
|
| 225 |
+ // Contains container's resources (cgroups, ulimits) |
|
| 226 |
+ Resources |
|
| 227 |
+} |
| 0 | 228 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,87 @@ |
| 0 |
+// +build !windows |
|
| 1 |
+ |
|
| 2 |
+package container |
|
| 3 |
+ |
|
| 4 |
+import "strings" |
|
| 5 |
+ |
|
| 6 |
+// IsValid indicates is an isolation level is valid |
|
| 7 |
+func (i IsolationLevel) IsValid() bool {
|
|
| 8 |
+ return i.IsDefault() |
|
| 9 |
+} |
|
| 10 |
+ |
|
| 11 |
+// IsPrivate indicates whether container uses it's private network stack. |
|
| 12 |
+func (n NetworkMode) IsPrivate() bool {
|
|
| 13 |
+ return !(n.IsHost() || n.IsContainer()) |
|
| 14 |
+} |
|
| 15 |
+ |
|
| 16 |
+// IsDefault indicates whether container uses the default network stack. |
|
| 17 |
+func (n NetworkMode) IsDefault() bool {
|
|
| 18 |
+ return n == "default" |
|
| 19 |
+} |
|
| 20 |
+ |
|
| 21 |
+// NetworkName returns the name of the network stack. |
|
| 22 |
+func (n NetworkMode) NetworkName() string {
|
|
| 23 |
+ if n.IsBridge() {
|
|
| 24 |
+ return "bridge" |
|
| 25 |
+ } else if n.IsHost() {
|
|
| 26 |
+ return "host" |
|
| 27 |
+ } else if n.IsContainer() {
|
|
| 28 |
+ return "container" |
|
| 29 |
+ } else if n.IsNone() {
|
|
| 30 |
+ return "none" |
|
| 31 |
+ } else if n.IsDefault() {
|
|
| 32 |
+ return "default" |
|
| 33 |
+ } else if n.IsUserDefined() {
|
|
| 34 |
+ return n.UserDefined() |
|
| 35 |
+ } |
|
| 36 |
+ return "" |
|
| 37 |
+} |
|
| 38 |
+ |
|
| 39 |
+// IsBridge indicates whether container uses the bridge network stack |
|
| 40 |
+func (n NetworkMode) IsBridge() bool {
|
|
| 41 |
+ return n == "bridge" |
|
| 42 |
+} |
|
| 43 |
+ |
|
| 44 |
+// IsHost indicates whether container uses the host network stack. |
|
| 45 |
+func (n NetworkMode) IsHost() bool {
|
|
| 46 |
+ return n == "host" |
|
| 47 |
+} |
|
| 48 |
+ |
|
| 49 |
+// IsContainer indicates whether container uses a container network stack. |
|
| 50 |
+func (n NetworkMode) IsContainer() bool {
|
|
| 51 |
+ parts := strings.SplitN(string(n), ":", 2) |
|
| 52 |
+ return len(parts) > 1 && parts[0] == "container" |
|
| 53 |
+} |
|
| 54 |
+ |
|
| 55 |
+// IsNone indicates whether container isn't using a network stack. |
|
| 56 |
+func (n NetworkMode) IsNone() bool {
|
|
| 57 |
+ return n == "none" |
|
| 58 |
+} |
|
| 59 |
+ |
|
| 60 |
+// ConnectedContainer is the id of the container which network this container is connected to. |
|
| 61 |
+func (n NetworkMode) ConnectedContainer() string {
|
|
| 62 |
+ parts := strings.SplitN(string(n), ":", 2) |
|
| 63 |
+ if len(parts) > 1 {
|
|
| 64 |
+ return parts[1] |
|
| 65 |
+ } |
|
| 66 |
+ return "" |
|
| 67 |
+} |
|
| 68 |
+ |
|
| 69 |
+// IsUserDefined indicates user-created network |
|
| 70 |
+func (n NetworkMode) IsUserDefined() bool {
|
|
| 71 |
+ return !n.IsDefault() && !n.IsBridge() && !n.IsHost() && !n.IsNone() && !n.IsContainer() |
|
| 72 |
+} |
|
| 73 |
+ |
|
| 74 |
+// IsPreDefinedNetwork indicates if a network is predefined by the daemon |
|
| 75 |
+func IsPreDefinedNetwork(network string) bool {
|
|
| 76 |
+ n := NetworkMode(network) |
|
| 77 |
+ return n.IsBridge() || n.IsHost() || n.IsNone() |
|
| 78 |
+} |
|
| 79 |
+ |
|
| 80 |
+//UserDefined indicates user-created network |
|
| 81 |
+func (n NetworkMode) UserDefined() string {
|
|
| 82 |
+ if n.IsUserDefined() {
|
|
| 83 |
+ return string(n) |
|
| 84 |
+ } |
|
| 85 |
+ return "" |
|
| 86 |
+} |
| 0 | 87 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,75 @@ |
| 0 |
+package container |
|
| 1 |
+ |
|
| 2 |
+import ( |
|
| 3 |
+ "fmt" |
|
| 4 |
+ "strings" |
|
| 5 |
+) |
|
| 6 |
+ |
|
| 7 |
+// IsDefault indicates whether container uses the default network stack. |
|
| 8 |
+func (n NetworkMode) IsDefault() bool {
|
|
| 9 |
+ return n == "default" |
|
| 10 |
+} |
|
| 11 |
+ |
|
| 12 |
+// IsHyperV indicates the use of a Hyper-V partition for isolation |
|
| 13 |
+func (i IsolationLevel) IsHyperV() bool {
|
|
| 14 |
+ return strings.ToLower(string(i)) == "hyperv" |
|
| 15 |
+} |
|
| 16 |
+ |
|
| 17 |
+// IsProcess indicates the use of process isolation |
|
| 18 |
+func (i IsolationLevel) IsProcess() bool {
|
|
| 19 |
+ return strings.ToLower(string(i)) == "process" |
|
| 20 |
+} |
|
| 21 |
+ |
|
| 22 |
+// IsValid indicates is an isolation level is valid |
|
| 23 |
+func (i IsolationLevel) IsValid() bool {
|
|
| 24 |
+ return i.IsDefault() || i.IsHyperV() || i.IsProcess() |
|
| 25 |
+} |
|
| 26 |
+ |
|
| 27 |
+// DefaultDaemonNetworkMode returns the default network stack the daemon should |
|
| 28 |
+// use. |
|
| 29 |
+func DefaultDaemonNetworkMode() NetworkMode {
|
|
| 30 |
+ return NetworkMode("default")
|
|
| 31 |
+} |
|
| 32 |
+ |
|
| 33 |
+// NetworkName returns the name of the network stack. |
|
| 34 |
+func (n NetworkMode) NetworkName() string {
|
|
| 35 |
+ if n.IsDefault() {
|
|
| 36 |
+ return "default" |
|
| 37 |
+ } |
|
| 38 |
+ return "" |
|
| 39 |
+} |
|
| 40 |
+ |
|
| 41 |
+// IsPreDefinedNetwork indicates if a network is predefined by the daemon |
|
| 42 |
+func IsPreDefinedNetwork(network string) bool {
|
|
| 43 |
+ return false |
|
| 44 |
+} |
|
| 45 |
+ |
|
| 46 |
+// ValidateNetMode ensures that the various combinations of requested |
|
| 47 |
+// network settings are valid. |
|
| 48 |
+func ValidateNetMode(c *Config, hc *HostConfig) error {
|
|
| 49 |
+ // We may not be passed a host config, such as in the case of docker commit |
|
| 50 |
+ if hc == nil {
|
|
| 51 |
+ return nil |
|
| 52 |
+ } |
|
| 53 |
+ parts := strings.Split(string(hc.NetworkMode), ":") |
|
| 54 |
+ switch mode := parts[0]; mode {
|
|
| 55 |
+ case "default", "none": |
|
| 56 |
+ default: |
|
| 57 |
+ return fmt.Errorf("invalid --net: %s", hc.NetworkMode)
|
|
| 58 |
+ } |
|
| 59 |
+ return nil |
|
| 60 |
+} |
|
| 61 |
+ |
|
| 62 |
+// ValidateIsolationLevel performs platform specific validation of the |
|
| 63 |
+// isolation level in the hostconfig structure. Windows supports 'default' (or |
|
| 64 |
+// blank), 'process', or 'hyperv'. |
|
| 65 |
+func ValidateIsolationLevel(hc *HostConfig) error {
|
|
| 66 |
+ // We may not be passed a host config, such as in the case of docker commit |
|
| 67 |
+ if hc == nil {
|
|
| 68 |
+ return nil |
|
| 69 |
+ } |
|
| 70 |
+ if !hc.Isolation.IsValid() {
|
|
| 71 |
+ return fmt.Errorf("invalid --isolation: %q. Windows supports 'default', 'process', or 'hyperv'", hc.Isolation)
|
|
| 72 |
+ } |
|
| 73 |
+ return nil |
|
| 74 |
+} |
| ... | ... |
@@ -4,10 +4,10 @@ import ( |
| 4 | 4 |
"os" |
| 5 | 5 |
"time" |
| 6 | 6 |
|
| 7 |
+ "github.com/docker/docker/api/types/container" |
|
| 7 | 8 |
"github.com/docker/docker/api/types/network" |
| 8 | 9 |
"github.com/docker/docker/api/types/registry" |
| 9 | 10 |
"github.com/docker/docker/pkg/version" |
| 10 |
- "github.com/docker/docker/runconfig" |
|
| 11 | 11 |
"github.com/docker/go-connections/nat" |
| 12 | 12 |
) |
| 13 | 13 |
|
| ... | ... |
@@ -103,10 +103,10 @@ type ImageInspect struct {
|
| 103 | 103 |
Comment string |
| 104 | 104 |
Created string |
| 105 | 105 |
Container string |
| 106 |
- ContainerConfig *runconfig.Config |
|
| 106 |
+ ContainerConfig *container.Config |
|
| 107 | 107 |
DockerVersion string |
| 108 | 108 |
Author string |
| 109 |
- Config *runconfig.Config |
|
| 109 |
+ Config *container.Config |
|
| 110 | 110 |
Architecture string |
| 111 | 111 |
Os string |
| 112 | 112 |
Size int64 |
| ... | ... |
@@ -283,7 +283,7 @@ type ContainerJSONBase struct {
|
| 283 | 283 |
ProcessLabel string |
| 284 | 284 |
AppArmorProfile string |
| 285 | 285 |
ExecIDs []string |
| 286 |
- HostConfig *runconfig.HostConfig |
|
| 286 |
+ HostConfig *container.HostConfig |
|
| 287 | 287 |
GraphDriver GraphDriverData |
| 288 | 288 |
SizeRw *int64 `json:",omitempty"` |
| 289 | 289 |
SizeRootFs *int64 `json:",omitempty"` |
| ... | ... |
@@ -293,7 +293,7 @@ type ContainerJSONBase struct {
|
| 293 | 293 |
type ContainerJSON struct {
|
| 294 | 294 |
*ContainerJSONBase |
| 295 | 295 |
Mounts []MountPoint |
| 296 |
- Config *runconfig.Config |
|
| 296 |
+ Config *container.Config |
|
| 297 | 297 |
NetworkSettings *NetworkSettings |
| 298 | 298 |
} |
| 299 | 299 |
|
| ... | ... |
@@ -3,8 +3,8 @@ package v1p19 |
| 3 | 3 |
|
| 4 | 4 |
import ( |
| 5 | 5 |
"github.com/docker/docker/api/types" |
| 6 |
+ "github.com/docker/docker/api/types/container" |
|
| 6 | 7 |
"github.com/docker/docker/api/types/versions/v1p20" |
| 7 |
- "github.com/docker/docker/runconfig" |
|
| 8 | 8 |
"github.com/docker/go-connections/nat" |
| 9 | 9 |
) |
| 10 | 10 |
|
| ... | ... |
@@ -20,7 +20,7 @@ type ContainerJSON struct {
|
| 20 | 20 |
|
| 21 | 21 |
// ContainerConfig is a backcompatibility struct for APIs prior to 1.20. |
| 22 | 22 |
type ContainerConfig struct {
|
| 23 |
- *runconfig.Config |
|
| 23 |
+ *container.Config |
|
| 24 | 24 |
|
| 25 | 25 |
MacAddress string |
| 26 | 26 |
NetworkDisabled bool |
| ... | ... |
@@ -3,7 +3,7 @@ package v1p20 |
| 3 | 3 |
|
| 4 | 4 |
import ( |
| 5 | 5 |
"github.com/docker/docker/api/types" |
| 6 |
- "github.com/docker/docker/runconfig" |
|
| 6 |
+ "github.com/docker/docker/api/types/container" |
|
| 7 | 7 |
"github.com/docker/go-connections/nat" |
| 8 | 8 |
) |
| 9 | 9 |
|
| ... | ... |
@@ -17,7 +17,7 @@ type ContainerJSON struct {
|
| 17 | 17 |
|
| 18 | 18 |
// ContainerConfig is a backcompatibility struct used in ContainerJSON for the API 1.20 |
| 19 | 19 |
type ContainerConfig struct {
|
| 20 |
- *runconfig.Config |
|
| 20 |
+ *container.Config |
|
| 21 | 21 |
|
| 22 | 22 |
MacAddress string |
| 23 | 23 |
NetworkDisabled bool |
| ... | ... |
@@ -10,7 +10,7 @@ import ( |
| 10 | 10 |
"time" |
| 11 | 11 |
|
| 12 | 12 |
"github.com/docker/docker/api/types" |
| 13 |
- "github.com/docker/docker/runconfig" |
|
| 13 |
+ "github.com/docker/docker/api/types/container" |
|
| 14 | 14 |
) |
| 15 | 15 |
|
| 16 | 16 |
// Context represents a file system tree. |
| ... | ... |
@@ -113,7 +113,7 @@ type Backend interface {
|
| 113 | 113 |
// Kill stops the container execution abruptly. |
| 114 | 114 |
ContainerKill(containerID string, sig uint64) error |
| 115 | 115 |
// Start starts a new container |
| 116 |
- ContainerStart(containerID string, hostConfig *runconfig.HostConfig) error |
|
| 116 |
+ ContainerStart(containerID string, hostConfig *container.HostConfig) error |
|
| 117 | 117 |
// ContainerWait stops processing until the given container is stopped. |
| 118 | 118 |
ContainerWait(containerID string, timeout time.Duration) (int, error) |
| 119 | 119 |
|
| ... | ... |
@@ -135,5 +135,5 @@ type Backend interface {
|
| 135 | 135 |
type ImageCache interface {
|
| 136 | 136 |
// GetCachedImage returns a reference to a cached image whose parent equals `parent` |
| 137 | 137 |
// and runconfig equals `cfg`. A cache miss is expected to return an empty ID and a nil error. |
| 138 |
- GetCachedImage(parentID string, cfg *runconfig.Config) (imageID string, err error) |
|
| 138 |
+ GetCachedImage(parentID string, cfg *container.Config) (imageID string, err error) |
|
| 139 | 139 |
} |
| ... | ... |
@@ -10,11 +10,11 @@ import ( |
| 10 | 10 |
"sync" |
| 11 | 11 |
|
| 12 | 12 |
"github.com/Sirupsen/logrus" |
| 13 |
+ "github.com/docker/docker/api/types/container" |
|
| 13 | 14 |
"github.com/docker/docker/builder" |
| 14 | 15 |
"github.com/docker/docker/builder/dockerfile/parser" |
| 15 | 16 |
"github.com/docker/docker/pkg/stringid" |
| 16 | 17 |
"github.com/docker/docker/pkg/ulimit" |
| 17 |
- "github.com/docker/docker/runconfig" |
|
| 18 | 18 |
) |
| 19 | 19 |
|
| 20 | 20 |
var validCommitCommands = map[string]bool{
|
| ... | ... |
@@ -52,7 +52,7 @@ type Config struct {
|
| 52 | 52 |
ForceRemove bool |
| 53 | 53 |
Pull bool |
| 54 | 54 |
BuildArgs map[string]string // build-time args received in build context for expansion/substitution and commands in 'run'. |
| 55 |
- Isolation runconfig.IsolationLevel |
|
| 55 |
+ Isolation container.IsolationLevel |
|
| 56 | 56 |
|
| 57 | 57 |
// resource constraints |
| 58 | 58 |
// TODO: factor out to be reused with Run ? |
| ... | ... |
@@ -81,7 +81,7 @@ type Builder struct {
|
| 81 | 81 |
context builder.Context |
| 82 | 82 |
|
| 83 | 83 |
dockerfile *parser.Node |
| 84 |
- runConfig *runconfig.Config // runconfig for cmd, run, entrypoint etc. |
|
| 84 |
+ runConfig *container.Config // runconfig for cmd, run, entrypoint etc. |
|
| 85 | 85 |
flags *BFlags |
| 86 | 86 |
tmpContainers map[string]struct{}
|
| 87 | 87 |
image string // imageID |
| ... | ... |
@@ -114,7 +114,7 @@ func NewBuilder(config *Config, docker builder.Backend, context builder.Context, |
| 114 | 114 |
Stderr: os.Stderr, |
| 115 | 115 |
docker: docker, |
| 116 | 116 |
context: context, |
| 117 |
- runConfig: new(runconfig.Config), |
|
| 117 |
+ runConfig: new(container.Config), |
|
| 118 | 118 |
tmpContainers: map[string]struct{}{},
|
| 119 | 119 |
cancelled: make(chan struct{}),
|
| 120 | 120 |
id: stringid.GenerateNonCryptoID(), |
| ... | ... |
@@ -206,7 +206,7 @@ func (b *Builder) Cancel() {
|
| 206 | 206 |
// - call parse.Parse() to get AST root from Dockerfile entries |
| 207 | 207 |
// - do build by calling builder.dispatch() to call all entries' handling routines |
| 208 | 208 |
// TODO: remove? |
| 209 |
-func BuildFromConfig(config *runconfig.Config, changes []string) (*runconfig.Config, error) {
|
|
| 209 |
+func BuildFromConfig(config *container.Config, changes []string) (*container.Config, error) {
|
|
| 210 | 210 |
ast, err := parser.Parse(bytes.NewBufferString(strings.Join(changes, "\n"))) |
| 211 | 211 |
if err != nil {
|
| 212 | 212 |
return nil, err |
| ... | ... |
@@ -21,6 +21,7 @@ import ( |
| 21 | 21 |
"github.com/Sirupsen/logrus" |
| 22 | 22 |
"github.com/docker/docker/api" |
| 23 | 23 |
"github.com/docker/docker/api/types" |
| 24 |
+ "github.com/docker/docker/api/types/container" |
|
| 24 | 25 |
"github.com/docker/docker/api/types/strslice" |
| 25 | 26 |
"github.com/docker/docker/builder" |
| 26 | 27 |
"github.com/docker/docker/builder/dockerfile/parser" |
| ... | ... |
@@ -34,7 +35,6 @@ import ( |
| 34 | 34 |
"github.com/docker/docker/pkg/system" |
| 35 | 35 |
"github.com/docker/docker/pkg/tarsum" |
| 36 | 36 |
"github.com/docker/docker/pkg/urlutil" |
| 37 |
- "github.com/docker/docker/runconfig" |
|
| 38 | 37 |
) |
| 39 | 38 |
|
| 40 | 39 |
func (b *Builder) commit(id string, autoCmd *strslice.StrSlice, comment string) error {
|
| ... | ... |
@@ -476,7 +476,7 @@ func (b *Builder) create() (string, error) {
|
| 476 | 476 |
} |
| 477 | 477 |
b.runConfig.Image = b.image |
| 478 | 478 |
|
| 479 |
- resources := runconfig.Resources{
|
|
| 479 |
+ resources := container.Resources{
|
|
| 480 | 480 |
CgroupParent: b.CgroupParent, |
| 481 | 481 |
CPUShares: b.CPUShares, |
| 482 | 482 |
CPUPeriod: b.CPUPeriod, |
| ... | ... |
@@ -489,7 +489,7 @@ func (b *Builder) create() (string, error) {
|
| 489 | 489 |
} |
| 490 | 490 |
|
| 491 | 491 |
// TODO: why not embed a hostconfig in builder? |
| 492 |
- hostConfig := &runconfig.HostConfig{
|
|
| 492 |
+ hostConfig := &container.HostConfig{
|
|
| 493 | 493 |
Isolation: b.Isolation, |
| 494 | 494 |
ShmSize: b.ShmSize, |
| 495 | 495 |
Resources: resources, |
| ... | ... |
@@ -1,9 +1,9 @@ |
| 1 | 1 |
package builder |
| 2 | 2 |
|
| 3 |
-import "github.com/docker/docker/runconfig" |
|
| 3 |
+import "github.com/docker/docker/api/types/container" |
|
| 4 | 4 |
|
| 5 | 5 |
// Image represents a Docker image used by the builder. |
| 6 | 6 |
type Image interface {
|
| 7 | 7 |
ID() string |
| 8 |
- Config() *runconfig.Config |
|
| 8 |
+ Config() *container.Config |
|
| 9 | 9 |
} |
| ... | ... |
@@ -11,6 +11,7 @@ import ( |
| 11 | 11 |
"time" |
| 12 | 12 |
|
| 13 | 13 |
"github.com/Sirupsen/logrus" |
| 14 |
+ containertypes "github.com/docker/docker/api/types/container" |
|
| 14 | 15 |
"github.com/docker/docker/daemon/exec" |
| 15 | 16 |
"github.com/docker/docker/daemon/execdriver" |
| 16 | 17 |
"github.com/docker/docker/daemon/logger" |
| ... | ... |
@@ -43,7 +44,7 @@ type CommonContainer struct {
|
| 43 | 43 |
Created time.Time |
| 44 | 44 |
Path string |
| 45 | 45 |
Args []string |
| 46 |
- Config *runconfig.Config |
|
| 46 |
+ Config *containertypes.Config |
|
| 47 | 47 |
ImageID image.ID `json:"Image"` |
| 48 | 48 |
NetworkSettings *network.Settings |
| 49 | 49 |
LogPath string |
| ... | ... |
@@ -56,8 +57,8 @@ type CommonContainer struct {
|
| 56 | 56 |
HasBeenStartedBefore bool |
| 57 | 57 |
HasBeenManuallyStopped bool // used for unless-stopped restart policy |
| 58 | 58 |
MountPoints map[string]*volume.MountPoint |
| 59 |
- HostConfig *runconfig.HostConfig `json:"-"` // do not serialize the host config in the json, otherwise we'll make the container unportable |
|
| 60 |
- Command *execdriver.Command `json:"-"` |
|
| 59 |
+ HostConfig *containertypes.HostConfig `json:"-"` // do not serialize the host config in the json, otherwise we'll make the container unportable |
|
| 60 |
+ Command *execdriver.Command `json:"-"` |
|
| 61 | 61 |
monitor *containerMonitor |
| 62 | 62 |
ExecCommands *exec.Store `json:"-"` |
| 63 | 63 |
// logDriver for closing |
| ... | ... |
@@ -139,7 +140,7 @@ func (container *Container) ToDiskLocking() error {
|
| 139 | 139 |
|
| 140 | 140 |
// readHostConfig reads the host configuration from disk for the container. |
| 141 | 141 |
func (container *Container) readHostConfig() error {
|
| 142 |
- container.HostConfig = &runconfig.HostConfig{}
|
|
| 142 |
+ container.HostConfig = &containertypes.HostConfig{}
|
|
| 143 | 143 |
// If the hostconfig file does not exist, do not read it. |
| 144 | 144 |
// (We still have to initialize container.HostConfig, |
| 145 | 145 |
// but that's OK, since we just did that above.) |
| ... | ... |
@@ -261,7 +262,7 @@ func (container *Container) exposes(p nat.Port) bool {
|
| 261 | 261 |
} |
| 262 | 262 |
|
| 263 | 263 |
// GetLogConfig returns the log configuration for the container. |
| 264 |
-func (container *Container) GetLogConfig(defaultConfig runconfig.LogConfig) runconfig.LogConfig {
|
|
| 264 |
+func (container *Container) GetLogConfig(defaultConfig containertypes.LogConfig) containertypes.LogConfig {
|
|
| 265 | 265 |
cfg := container.HostConfig.LogConfig |
| 266 | 266 |
if cfg.Type != "" || len(cfg.Config) > 0 { // container has log driver configured
|
| 267 | 267 |
if cfg.Type == "" {
|
| ... | ... |
@@ -274,7 +275,7 @@ func (container *Container) GetLogConfig(defaultConfig runconfig.LogConfig) runc |
| 274 | 274 |
} |
| 275 | 275 |
|
| 276 | 276 |
// StartLogger starts a new logger driver for the container. |
| 277 |
-func (container *Container) StartLogger(cfg runconfig.LogConfig) (logger.Logger, error) {
|
|
| 277 |
+func (container *Container) StartLogger(cfg containertypes.LogConfig) (logger.Logger, error) {
|
|
| 278 | 278 |
c, err := logger.GetLogDriver(cfg.Type) |
| 279 | 279 |
if err != nil {
|
| 280 | 280 |
return nil, derr.ErrorCodeLoggingFactory.WithArgs(err) |
| ... | ... |
@@ -3,14 +3,14 @@ package container |
| 3 | 3 |
import ( |
| 4 | 4 |
"testing" |
| 5 | 5 |
|
| 6 |
+ "github.com/docker/docker/api/types/container" |
|
| 6 | 7 |
"github.com/docker/docker/pkg/signal" |
| 7 |
- "github.com/docker/docker/runconfig" |
|
| 8 | 8 |
) |
| 9 | 9 |
|
| 10 | 10 |
func TestContainerStopSignal(t *testing.T) {
|
| 11 | 11 |
c := &Container{
|
| 12 | 12 |
CommonContainer: CommonContainer{
|
| 13 |
- Config: &runconfig.Config{},
|
|
| 13 |
+ Config: &container.Config{},
|
|
| 14 | 14 |
}, |
| 15 | 15 |
} |
| 16 | 16 |
|
| ... | ... |
@@ -26,7 +26,7 @@ func TestContainerStopSignal(t *testing.T) {
|
| 26 | 26 |
|
| 27 | 27 |
c = &Container{
|
| 28 | 28 |
CommonContainer: CommonContainer{
|
| 29 |
- Config: &runconfig.Config{StopSignal: "SIGKILL"},
|
|
| 29 |
+ Config: &container.Config{StopSignal: "SIGKILL"},
|
|
| 30 | 30 |
}, |
| 31 | 31 |
} |
| 32 | 32 |
s = c.StopSignal() |
| ... | ... |
@@ -9,11 +9,11 @@ import ( |
| 9 | 9 |
"time" |
| 10 | 10 |
|
| 11 | 11 |
"github.com/Sirupsen/logrus" |
| 12 |
+ "github.com/docker/docker/api/types/container" |
|
| 12 | 13 |
"github.com/docker/docker/daemon/execdriver" |
| 13 | 14 |
derr "github.com/docker/docker/errors" |
| 14 | 15 |
"github.com/docker/docker/pkg/promise" |
| 15 | 16 |
"github.com/docker/docker/pkg/stringid" |
| 16 |
- "github.com/docker/docker/runconfig" |
|
| 17 | 17 |
"github.com/docker/docker/utils" |
| 18 | 18 |
) |
| 19 | 19 |
|
| ... | ... |
@@ -51,7 +51,7 @@ type containerMonitor struct {
|
| 51 | 51 |
container *Container |
| 52 | 52 |
|
| 53 | 53 |
// restartPolicy is the current policy being applied to the container monitor |
| 54 |
- restartPolicy runconfig.RestartPolicy |
|
| 54 |
+ restartPolicy container.RestartPolicy |
|
| 55 | 55 |
|
| 56 | 56 |
// failureCount is the number of times the container has failed to |
| 57 | 57 |
// start in a row |
| ... | ... |
@@ -79,7 +79,7 @@ type containerMonitor struct {
|
| 79 | 79 |
|
| 80 | 80 |
// StartMonitor initializes a containerMonitor for this container with the provided supervisor and restart policy |
| 81 | 81 |
// and starts the container's process. |
| 82 |
-func (container *Container) StartMonitor(s supervisor, policy runconfig.RestartPolicy) error {
|
|
| 82 |
+func (container *Container) StartMonitor(s supervisor, policy container.RestartPolicy) error {
|
|
| 83 | 83 |
container.monitor = &containerMonitor{
|
| 84 | 84 |
supervisor: s, |
| 85 | 85 |
container: container, |
| ... | ... |
@@ -1,9 +1,9 @@ |
| 1 | 1 |
package daemon |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 |
+ "github.com/docker/docker/api/types/container" |
|
| 4 | 5 |
"github.com/docker/docker/opts" |
| 5 | 6 |
flag "github.com/docker/docker/pkg/mflag" |
| 6 |
- "github.com/docker/docker/runconfig" |
|
| 7 | 7 |
) |
| 8 | 8 |
|
| 9 | 9 |
const ( |
| ... | ... |
@@ -27,7 +27,7 @@ type CommonConfig struct {
|
| 27 | 27 |
GraphDriver string |
| 28 | 28 |
GraphOptions []string |
| 29 | 29 |
Labels []string |
| 30 |
- LogConfig runconfig.LogConfig |
|
| 30 |
+ LogConfig container.LogConfig |
|
| 31 | 31 |
Mtu int |
| 32 | 32 |
Pidfile string |
| 33 | 33 |
RemappedRoot string |
| ... | ... |
@@ -13,6 +13,7 @@ import ( |
| 13 | 13 |
"time" |
| 14 | 14 |
|
| 15 | 15 |
"github.com/Sirupsen/logrus" |
| 16 |
+ containertypes "github.com/docker/docker/api/types/container" |
|
| 16 | 17 |
networktypes "github.com/docker/docker/api/types/network" |
| 17 | 18 |
"github.com/docker/docker/container" |
| 18 | 19 |
"github.com/docker/docker/daemon/execdriver" |
| ... | ... |
@@ -460,7 +461,7 @@ func (daemon *Daemon) updateNetworkSettings(container *container.Container, n li |
| 460 | 460 |
container.NetworkSettings = &network.Settings{Networks: make(map[string]*networktypes.EndpointSettings)}
|
| 461 | 461 |
} |
| 462 | 462 |
|
| 463 |
- if !container.HostConfig.NetworkMode.IsHost() && runconfig.NetworkMode(n.Type()).IsHost() {
|
|
| 463 |
+ if !container.HostConfig.NetworkMode.IsHost() && containertypes.NetworkMode(n.Type()).IsHost() {
|
|
| 464 | 464 |
return runconfig.ErrConflictHostNetwork |
| 465 | 465 |
} |
| 466 | 466 |
|
| ... | ... |
@@ -474,12 +475,12 @@ func (daemon *Daemon) updateNetworkSettings(container *container.Container, n li |
| 474 | 474 |
// Avoid duplicate config |
| 475 | 475 |
return nil |
| 476 | 476 |
} |
| 477 |
- if !runconfig.NetworkMode(sn.Type()).IsPrivate() || |
|
| 478 |
- !runconfig.NetworkMode(n.Type()).IsPrivate() {
|
|
| 477 |
+ if !containertypes.NetworkMode(sn.Type()).IsPrivate() || |
|
| 478 |
+ !containertypes.NetworkMode(n.Type()).IsPrivate() {
|
|
| 479 | 479 |
return runconfig.ErrConflictSharedNetwork |
| 480 | 480 |
} |
| 481 |
- if runconfig.NetworkMode(sn.Name()).IsNone() || |
|
| 482 |
- runconfig.NetworkMode(n.Name()).IsNone() {
|
|
| 481 |
+ if containertypes.NetworkMode(sn.Name()).IsNone() || |
|
| 482 |
+ containertypes.NetworkMode(n.Name()).IsNone() {
|
|
| 483 | 483 |
return runconfig.ErrConflictNoNetwork |
| 484 | 484 |
} |
| 485 | 485 |
} |
| ... | ... |
@@ -493,7 +494,7 @@ func (daemon *Daemon) updateEndpointNetworkSettings(container *container.Contain |
| 493 | 493 |
return err |
| 494 | 494 |
} |
| 495 | 495 |
|
| 496 |
- if container.HostConfig.NetworkMode == runconfig.NetworkMode("bridge") {
|
|
| 496 |
+ if container.HostConfig.NetworkMode == containertypes.NetworkMode("bridge") {
|
|
| 497 | 497 |
container.NetworkSettings.Bridge = daemon.configStore.Bridge.Iface |
| 498 | 498 |
} |
| 499 | 499 |
|
| ... | ... |
@@ -625,7 +626,7 @@ func (daemon *Daemon) connectToNetwork(container *container.Container, idOrName |
| 625 | 625 |
return runconfig.ErrConflictSharedNetwork |
| 626 | 626 |
} |
| 627 | 627 |
|
| 628 |
- if runconfig.NetworkMode(idOrName).IsBridge() && |
|
| 628 |
+ if containertypes.NetworkMode(idOrName).IsBridge() && |
|
| 629 | 629 |
daemon.configStore.DisableBridge {
|
| 630 | 630 |
container.Config.NetworkDisabled = true |
| 631 | 631 |
return nil |
| ... | ... |
@@ -706,7 +707,7 @@ func (daemon *Daemon) DisconnectFromNetwork(container *container.Container, n li |
| 706 | 706 |
return derr.ErrorCodeNotRunning.WithArgs(container.ID) |
| 707 | 707 |
} |
| 708 | 708 |
|
| 709 |
- if container.HostConfig.NetworkMode.IsHost() && runconfig.NetworkMode(n.Type()).IsHost() {
|
|
| 709 |
+ if container.HostConfig.NetworkMode.IsHost() && containertypes.NetworkMode(n.Type()).IsHost() {
|
|
| 710 | 710 |
return runconfig.ErrConflictHostNetwork |
| 711 | 711 |
} |
| 712 | 712 |
|
| ... | ... |
@@ -955,7 +956,7 @@ func killProcessDirectly(container *container.Container) error {
|
| 955 | 955 |
return nil |
| 956 | 956 |
} |
| 957 | 957 |
|
| 958 |
-func getDevicesFromPath(deviceMapping runconfig.DeviceMapping) (devs []*configs.Device, err error) {
|
|
| 958 |
+func getDevicesFromPath(deviceMapping containertypes.DeviceMapping) (devs []*configs.Device, err error) {
|
|
| 959 | 959 |
device, err := devices.DeviceFromPath(deviceMapping.PathOnHost, deviceMapping.CgroupPermissions) |
| 960 | 960 |
// if there was no error, return the device |
| 961 | 961 |
if err == nil {
|
| ... | ... |
@@ -7,6 +7,7 @@ import ( |
| 7 | 7 |
|
| 8 | 8 |
"github.com/docker/docker/container" |
| 9 | 9 |
"github.com/docker/docker/daemon/execdriver" |
| 10 |
+ "github.com/docker/docker/daemon/execdriver/windows" |
|
| 10 | 11 |
derr "github.com/docker/docker/errors" |
| 11 | 12 |
"github.com/docker/docker/layer" |
| 12 | 13 |
"github.com/docker/libnetwork" |
| ... | ... |
@@ -103,6 +104,16 @@ func (daemon *Daemon) populateCommand(c *container.Container, env []string) erro |
| 103 | 103 |
} |
| 104 | 104 |
layerFolder := m["dir"] |
| 105 | 105 |
|
| 106 |
+ var hvPartition bool |
|
| 107 |
+ // Work out the isolation (whether it is a hypervisor partition) |
|
| 108 |
+ if c.HostConfig.Isolation.IsDefault() {
|
|
| 109 |
+ // Not specified by caller. Take daemon default |
|
| 110 |
+ hvPartition = windows.DefaultIsolation.IsHyperV() |
|
| 111 |
+ } else {
|
|
| 112 |
+ // Take value specified by caller |
|
| 113 |
+ hvPartition = c.HostConfig.Isolation.IsHyperV() |
|
| 114 |
+ } |
|
| 115 |
+ |
|
| 106 | 116 |
c.Command = &execdriver.Command{
|
| 107 | 117 |
CommonCommand: execdriver.CommonCommand{
|
| 108 | 118 |
ID: c.ID, |
| ... | ... |
@@ -119,8 +130,9 @@ func (daemon *Daemon) populateCommand(c *container.Container, env []string) erro |
| 119 | 119 |
LayerFolder: layerFolder, |
| 120 | 120 |
LayerPaths: layerPaths, |
| 121 | 121 |
Hostname: c.Config.Hostname, |
| 122 |
- Isolation: c.HostConfig.Isolation, |
|
| 122 |
+ Isolation: string(c.HostConfig.Isolation), |
|
| 123 | 123 |
ArgsEscaped: c.Config.ArgsEscaped, |
| 124 |
+ HvPartition: hvPartition, |
|
| 124 | 125 |
} |
| 125 | 126 |
|
| 126 | 127 |
return nil |
| ... | ... |
@@ -3,12 +3,12 @@ package daemon |
| 3 | 3 |
import ( |
| 4 | 4 |
"github.com/Sirupsen/logrus" |
| 5 | 5 |
"github.com/docker/docker/api/types" |
| 6 |
+ containertypes "github.com/docker/docker/api/types/container" |
|
| 6 | 7 |
"github.com/docker/docker/container" |
| 7 | 8 |
derr "github.com/docker/docker/errors" |
| 8 | 9 |
"github.com/docker/docker/image" |
| 9 | 10 |
"github.com/docker/docker/pkg/idtools" |
| 10 | 11 |
"github.com/docker/docker/pkg/stringid" |
| 11 |
- "github.com/docker/docker/runconfig" |
|
| 12 | 12 |
"github.com/docker/docker/volume" |
| 13 | 13 |
"github.com/opencontainers/runc/libcontainer/label" |
| 14 | 14 |
) |
| ... | ... |
@@ -25,7 +25,7 @@ func (daemon *Daemon) ContainerCreate(params types.ContainerCreateConfig) (types |
| 25 | 25 |
} |
| 26 | 26 |
|
| 27 | 27 |
if params.HostConfig == nil {
|
| 28 |
- params.HostConfig = &runconfig.HostConfig{}
|
|
| 28 |
+ params.HostConfig = &containertypes.HostConfig{}
|
|
| 29 | 29 |
} |
| 30 | 30 |
err = daemon.adaptContainerSettings(params.HostConfig, params.AdjustCPUShares) |
| 31 | 31 |
if err != nil {
|
| ... | ... |
@@ -111,7 +111,7 @@ func (daemon *Daemon) create(params types.ContainerCreateConfig) (*container.Con |
| 111 | 111 |
return container, nil |
| 112 | 112 |
} |
| 113 | 113 |
|
| 114 |
-func (daemon *Daemon) generateSecurityOpt(ipcMode runconfig.IpcMode, pidMode runconfig.PidMode) ([]string, error) {
|
|
| 114 |
+func (daemon *Daemon) generateSecurityOpt(ipcMode containertypes.IpcMode, pidMode containertypes.PidMode) ([]string, error) {
|
|
| 115 | 115 |
if ipcMode.IsHost() || pidMode.IsHost() {
|
| 116 | 116 |
return label.DisableSecOpt(), nil |
| 117 | 117 |
} |
| ... | ... |
@@ -6,17 +6,17 @@ import ( |
| 6 | 6 |
"os" |
| 7 | 7 |
"path/filepath" |
| 8 | 8 |
|
| 9 |
+ containertypes "github.com/docker/docker/api/types/container" |
|
| 9 | 10 |
"github.com/docker/docker/container" |
| 10 | 11 |
derr "github.com/docker/docker/errors" |
| 11 | 12 |
"github.com/docker/docker/image" |
| 12 | 13 |
"github.com/docker/docker/pkg/stringid" |
| 13 |
- "github.com/docker/docker/runconfig" |
|
| 14 | 14 |
"github.com/docker/docker/volume" |
| 15 | 15 |
"github.com/opencontainers/runc/libcontainer/label" |
| 16 | 16 |
) |
| 17 | 17 |
|
| 18 | 18 |
// createContainerPlatformSpecificSettings performs platform specific container create functionality |
| 19 |
-func (daemon *Daemon) createContainerPlatformSpecificSettings(container *container.Container, config *runconfig.Config, hostConfig *runconfig.HostConfig, img *image.Image) error {
|
|
| 19 |
+func (daemon *Daemon) createContainerPlatformSpecificSettings(container *container.Container, config *containertypes.Config, hostConfig *containertypes.HostConfig, img *image.Image) error {
|
|
| 20 | 20 |
if err := daemon.Mount(container); err != nil {
|
| 21 | 21 |
return err |
| 22 | 22 |
} |
| ... | ... |
@@ -3,15 +3,15 @@ package daemon |
| 3 | 3 |
import ( |
| 4 | 4 |
"fmt" |
| 5 | 5 |
|
| 6 |
+ containertypes "github.com/docker/docker/api/types/container" |
|
| 6 | 7 |
"github.com/docker/docker/container" |
| 7 | 8 |
"github.com/docker/docker/image" |
| 8 | 9 |
"github.com/docker/docker/pkg/stringid" |
| 9 |
- "github.com/docker/docker/runconfig" |
|
| 10 | 10 |
"github.com/docker/docker/volume" |
| 11 | 11 |
) |
| 12 | 12 |
|
| 13 | 13 |
// createContainerPlatformSpecificSettings performs platform specific container create functionality |
| 14 |
-func (daemon *Daemon) createContainerPlatformSpecificSettings(container *container.Container, config *runconfig.Config, hostConfig *runconfig.HostConfig, img *image.Image) error {
|
|
| 14 |
+func (daemon *Daemon) createContainerPlatformSpecificSettings(container *container.Container, config *containertypes.Config, hostConfig *containertypes.HostConfig, img *image.Image) error {
|
|
| 15 | 15 |
for spec := range config.Volumes {
|
| 16 | 16 |
|
| 17 | 17 |
mp, err := volume.ParseMountSpec(spec, hostConfig.VolumeDriver) |
| ... | ... |
@@ -21,6 +21,7 @@ import ( |
| 21 | 21 |
"github.com/docker/distribution/digest" |
| 22 | 22 |
"github.com/docker/docker/api" |
| 23 | 23 |
"github.com/docker/docker/api/types" |
| 24 |
+ containertypes "github.com/docker/docker/api/types/container" |
|
| 24 | 25 |
"github.com/docker/docker/api/types/filters" |
| 25 | 26 |
registrytypes "github.com/docker/docker/api/types/registry" |
| 26 | 27 |
"github.com/docker/docker/api/types/strslice" |
| ... | ... |
@@ -148,7 +149,7 @@ type Daemon struct {
|
| 148 | 148 |
driver graphdriver.Driver |
| 149 | 149 |
execDriver execdriver.Driver |
| 150 | 150 |
statsCollector *statsCollector |
| 151 |
- defaultLogConfig runconfig.LogConfig |
|
| 151 |
+ defaultLogConfig containertypes.LogConfig |
|
| 152 | 152 |
RegistryService *registry.Service |
| 153 | 153 |
EventsService *events.Events |
| 154 | 154 |
netController libnetwork.NetworkController |
| ... | ... |
@@ -390,7 +391,7 @@ func (daemon *Daemon) restore() error {
|
| 390 | 390 |
return nil |
| 391 | 391 |
} |
| 392 | 392 |
|
| 393 |
-func (daemon *Daemon) mergeAndVerifyConfig(config *runconfig.Config, img *image.Image) error {
|
|
| 393 |
+func (daemon *Daemon) mergeAndVerifyConfig(config *containertypes.Config, img *image.Image) error {
|
|
| 394 | 394 |
if img != nil && img.Config != nil {
|
| 395 | 395 |
if err := runconfig.Merge(config, img.Config); err != nil {
|
| 396 | 396 |
return err |
| ... | ... |
@@ -472,7 +473,7 @@ func (daemon *Daemon) generateNewName(id string) (string, error) {
|
| 472 | 472 |
return name, nil |
| 473 | 473 |
} |
| 474 | 474 |
|
| 475 |
-func (daemon *Daemon) generateHostname(id string, config *runconfig.Config) {
|
|
| 475 |
+func (daemon *Daemon) generateHostname(id string, config *containertypes.Config) {
|
|
| 476 | 476 |
// Generate default hostname |
| 477 | 477 |
if config.Hostname == "" {
|
| 478 | 478 |
config.Hostname = id[:12] |
| ... | ... |
@@ -488,7 +489,7 @@ func (daemon *Daemon) getEntrypointAndArgs(configEntrypoint *strslice.StrSlice, |
| 488 | 488 |
return cmdSlice[0], cmdSlice[1:] |
| 489 | 489 |
} |
| 490 | 490 |
|
| 491 |
-func (daemon *Daemon) newContainer(name string, config *runconfig.Config, imgID image.ID) (*container.Container, error) {
|
|
| 491 |
+func (daemon *Daemon) newContainer(name string, config *containertypes.Config, imgID image.ID) (*container.Container, error) {
|
|
| 492 | 492 |
var ( |
| 493 | 493 |
id string |
| 494 | 494 |
err error |
| ... | ... |
@@ -507,7 +508,7 @@ func (daemon *Daemon) newContainer(name string, config *runconfig.Config, imgID |
| 507 | 507 |
base.Path = entrypoint |
| 508 | 508 |
base.Args = args //FIXME: de-duplicate from config |
| 509 | 509 |
base.Config = config |
| 510 |
- base.HostConfig = &runconfig.HostConfig{}
|
|
| 510 |
+ base.HostConfig = &containertypes.HostConfig{}
|
|
| 511 | 511 |
base.ImageID = imgID |
| 512 | 512 |
base.NetworkSettings = &network.Settings{IsAnonymousEndpoint: noExplicitName}
|
| 513 | 513 |
base.Name = name |
| ... | ... |
@@ -1366,7 +1367,7 @@ func (daemon *Daemon) GetRemappedUIDGID() (int, int) {
|
| 1366 | 1366 |
// of the image with imgID, that had the same config when it was |
| 1367 | 1367 |
// created. nil is returned if a child cannot be found. An error is |
| 1368 | 1368 |
// returned if the parent image cannot be found. |
| 1369 |
-func (daemon *Daemon) ImageGetCached(imgID image.ID, config *runconfig.Config) (*image.Image, error) {
|
|
| 1369 |
+func (daemon *Daemon) ImageGetCached(imgID image.ID, config *containertypes.Config) (*image.Image, error) {
|
|
| 1370 | 1370 |
// Retrieve all images |
| 1371 | 1371 |
imgs := daemon.Map() |
| 1372 | 1372 |
|
| ... | ... |
@@ -1402,7 +1403,7 @@ func tempDir(rootDir string, rootUID, rootGID int) (string, error) {
|
| 1402 | 1402 |
return tmpDir, idtools.MkdirAllAs(tmpDir, 0700, rootUID, rootGID) |
| 1403 | 1403 |
} |
| 1404 | 1404 |
|
| 1405 |
-func (daemon *Daemon) setHostConfig(container *container.Container, hostConfig *runconfig.HostConfig) error {
|
|
| 1405 |
+func (daemon *Daemon) setHostConfig(container *container.Container, hostConfig *containertypes.HostConfig) error {
|
|
| 1406 | 1406 |
container.Lock() |
| 1407 | 1407 |
if err := parseSecurityOpt(container, hostConfig); err != nil {
|
| 1408 | 1408 |
container.Unlock() |
| ... | ... |
@@ -1444,7 +1445,7 @@ func setDefaultMtu(config *Config) {
|
| 1444 | 1444 |
|
| 1445 | 1445 |
// verifyContainerSettings performs validation of the hostconfig and config |
| 1446 | 1446 |
// structures. |
| 1447 |
-func (daemon *Daemon) verifyContainerSettings(hostConfig *runconfig.HostConfig, config *runconfig.Config) ([]string, error) {
|
|
| 1447 |
+func (daemon *Daemon) verifyContainerSettings(hostConfig *containertypes.HostConfig, config *containertypes.Config) ([]string, error) {
|
|
| 1448 | 1448 |
|
| 1449 | 1449 |
// First perform verification of settings common across all platforms. |
| 1450 | 1450 |
if config != nil {
|
| ... | ... |
@@ -9,9 +9,9 @@ import ( |
| 9 | 9 |
"runtime" |
| 10 | 10 |
|
| 11 | 11 |
"github.com/Sirupsen/logrus" |
| 12 |
+ "github.com/docker/docker/api/types/container" |
|
| 12 | 13 |
"github.com/docker/docker/pkg/directory" |
| 13 | 14 |
"github.com/docker/docker/pkg/idtools" |
| 14 |
- "github.com/docker/docker/runconfig" |
|
| 15 | 15 |
) |
| 16 | 16 |
|
| 17 | 17 |
func setupRemappedRoot(config *Config) ([]idtools.IDMap, []idtools.IDMap, error) {
|
| ... | ... |
@@ -99,7 +99,7 @@ func setupDaemonRoot(config *Config, rootDir string, rootUID, rootGID int) error |
| 99 | 99 |
return nil |
| 100 | 100 |
} |
| 101 | 101 |
|
| 102 |
-func (daemon *Daemon) verifyExperimentalContainerSettings(hostConfig *runconfig.HostConfig, config *runconfig.Config) ([]string, error) {
|
|
| 102 |
+func (daemon *Daemon) verifyExperimentalContainerSettings(hostConfig *container.HostConfig, config *container.Config) ([]string, error) {
|
|
| 103 | 103 |
if hostConfig.Privileged && daemon.configStore.RemappedRoot != "" {
|
| 104 | 104 |
return nil, fmt.Errorf("Privileged mode is incompatible with user namespace mappings")
|
| 105 | 105 |
} |
| ... | ... |
@@ -5,9 +5,9 @@ package daemon |
| 5 | 5 |
import ( |
| 6 | 6 |
"os" |
| 7 | 7 |
|
| 8 |
+ "github.com/docker/docker/api/types/container" |
|
| 8 | 9 |
"github.com/docker/docker/pkg/idtools" |
| 9 | 10 |
"github.com/docker/docker/pkg/system" |
| 10 |
- "github.com/docker/docker/runconfig" |
|
| 11 | 11 |
) |
| 12 | 12 |
|
| 13 | 13 |
func setupRemappedRoot(config *Config) ([]idtools.IDMap, []idtools.IDMap, error) {
|
| ... | ... |
@@ -23,6 +23,6 @@ func setupDaemonRoot(config *Config, rootDir string, rootUID, rootGID int) error |
| 23 | 23 |
return nil |
| 24 | 24 |
} |
| 25 | 25 |
|
| 26 |
-func (daemon *Daemon) verifyExperimentalContainerSettings(hostConfig *runconfig.HostConfig, config *runconfig.Config) ([]string, error) {
|
|
| 26 |
+func (daemon *Daemon) verifyExperimentalContainerSettings(hostConfig *container.HostConfig, config *container.Config) ([]string, error) {
|
|
| 27 | 27 |
return nil, nil |
| 28 | 28 |
} |
| ... | ... |
@@ -7,10 +7,10 @@ import ( |
| 7 | 7 |
"path/filepath" |
| 8 | 8 |
"testing" |
| 9 | 9 |
|
| 10 |
+ containertypes "github.com/docker/docker/api/types/container" |
|
| 10 | 11 |
"github.com/docker/docker/container" |
| 11 | 12 |
"github.com/docker/docker/pkg/graphdb" |
| 12 | 13 |
"github.com/docker/docker/pkg/truncindex" |
| 13 |
- "github.com/docker/docker/runconfig" |
|
| 14 | 14 |
"github.com/docker/docker/volume" |
| 15 | 15 |
volumedrivers "github.com/docker/docker/volume/drivers" |
| 16 | 16 |
"github.com/docker/docker/volume/local" |
| ... | ... |
@@ -141,7 +141,7 @@ func initDaemonWithVolumeStore(tmp string) (*Daemon, error) {
|
| 141 | 141 |
|
| 142 | 142 |
func TestParseSecurityOpt(t *testing.T) {
|
| 143 | 143 |
container := &container.Container{}
|
| 144 |
- config := &runconfig.HostConfig{}
|
|
| 144 |
+ config := &containertypes.HostConfig{}
|
|
| 145 | 145 |
|
| 146 | 146 |
// test apparmor |
| 147 | 147 |
config.SecurityOpt = []string{"apparmor:test_profile"}
|
| ... | ... |
@@ -13,6 +13,7 @@ import ( |
| 13 | 13 |
|
| 14 | 14 |
"github.com/Sirupsen/logrus" |
| 15 | 15 |
pblkiodev "github.com/docker/docker/api/types/blkiodev" |
| 16 |
+ containertypes "github.com/docker/docker/api/types/container" |
|
| 16 | 17 |
"github.com/docker/docker/container" |
| 17 | 18 |
"github.com/docker/docker/daemon/graphdriver" |
| 18 | 19 |
derr "github.com/docker/docker/errors" |
| ... | ... |
@@ -43,7 +44,7 @@ const ( |
| 43 | 43 |
linuxMinMemory = 4194304 |
| 44 | 44 |
) |
| 45 | 45 |
|
| 46 |
-func getBlkioWeightDevices(config *runconfig.HostConfig) ([]*blkiodev.WeightDevice, error) {
|
|
| 46 |
+func getBlkioWeightDevices(config *containertypes.HostConfig) ([]*blkiodev.WeightDevice, error) {
|
|
| 47 | 47 |
var stat syscall.Stat_t |
| 48 | 48 |
var blkioWeightDevices []*blkiodev.WeightDevice |
| 49 | 49 |
|
| ... | ... |
@@ -58,7 +59,7 @@ func getBlkioWeightDevices(config *runconfig.HostConfig) ([]*blkiodev.WeightDevi |
| 58 | 58 |
return blkioWeightDevices, nil |
| 59 | 59 |
} |
| 60 | 60 |
|
| 61 |
-func parseSecurityOpt(container *container.Container, config *runconfig.HostConfig) error {
|
|
| 61 |
+func parseSecurityOpt(container *container.Container, config *containertypes.HostConfig) error {
|
|
| 62 | 62 |
var ( |
| 63 | 63 |
labelOpts []string |
| 64 | 64 |
err error |
| ... | ... |
@@ -85,7 +86,7 @@ func parseSecurityOpt(container *container.Container, config *runconfig.HostConf |
| 85 | 85 |
return err |
| 86 | 86 |
} |
| 87 | 87 |
|
| 88 |
-func getBlkioReadIOpsDevices(config *runconfig.HostConfig) ([]*blkiodev.ThrottleDevice, error) {
|
|
| 88 |
+func getBlkioReadIOpsDevices(config *containertypes.HostConfig) ([]*blkiodev.ThrottleDevice, error) {
|
|
| 89 | 89 |
var blkioReadIOpsDevice []*blkiodev.ThrottleDevice |
| 90 | 90 |
var stat syscall.Stat_t |
| 91 | 91 |
|
| ... | ... |
@@ -100,7 +101,7 @@ func getBlkioReadIOpsDevices(config *runconfig.HostConfig) ([]*blkiodev.Throttle |
| 100 | 100 |
return blkioReadIOpsDevice, nil |
| 101 | 101 |
} |
| 102 | 102 |
|
| 103 |
-func getBlkioWriteIOpsDevices(config *runconfig.HostConfig) ([]*blkiodev.ThrottleDevice, error) {
|
|
| 103 |
+func getBlkioWriteIOpsDevices(config *containertypes.HostConfig) ([]*blkiodev.ThrottleDevice, error) {
|
|
| 104 | 104 |
var blkioWriteIOpsDevice []*blkiodev.ThrottleDevice |
| 105 | 105 |
var stat syscall.Stat_t |
| 106 | 106 |
|
| ... | ... |
@@ -115,7 +116,7 @@ func getBlkioWriteIOpsDevices(config *runconfig.HostConfig) ([]*blkiodev.Throttl |
| 115 | 115 |
return blkioWriteIOpsDevice, nil |
| 116 | 116 |
} |
| 117 | 117 |
|
| 118 |
-func getBlkioReadBpsDevices(config *runconfig.HostConfig) ([]*blkiodev.ThrottleDevice, error) {
|
|
| 118 |
+func getBlkioReadBpsDevices(config *containertypes.HostConfig) ([]*blkiodev.ThrottleDevice, error) {
|
|
| 119 | 119 |
var blkioReadBpsDevice []*blkiodev.ThrottleDevice |
| 120 | 120 |
var stat syscall.Stat_t |
| 121 | 121 |
|
| ... | ... |
@@ -130,7 +131,7 @@ func getBlkioReadBpsDevices(config *runconfig.HostConfig) ([]*blkiodev.ThrottleD |
| 130 | 130 |
return blkioReadBpsDevice, nil |
| 131 | 131 |
} |
| 132 | 132 |
|
| 133 |
-func getBlkioWriteBpsDevices(config *runconfig.HostConfig) ([]*blkiodev.ThrottleDevice, error) {
|
|
| 133 |
+func getBlkioWriteBpsDevices(config *containertypes.HostConfig) ([]*blkiodev.ThrottleDevice, error) {
|
|
| 134 | 134 |
var blkioWriteBpsDevice []*blkiodev.ThrottleDevice |
| 135 | 135 |
var stat syscall.Stat_t |
| 136 | 136 |
|
| ... | ... |
@@ -175,7 +176,7 @@ func checkKernel() error {
|
| 175 | 175 |
|
| 176 | 176 |
// adaptContainerSettings is called during container creation to modify any |
| 177 | 177 |
// settings necessary in the HostConfig structure. |
| 178 |
-func (daemon *Daemon) adaptContainerSettings(hostConfig *runconfig.HostConfig, adjustCPUShares bool) error {
|
|
| 178 |
+func (daemon *Daemon) adaptContainerSettings(hostConfig *containertypes.HostConfig, adjustCPUShares bool) error {
|
|
| 179 | 179 |
if adjustCPUShares && hostConfig.CPUShares > 0 {
|
| 180 | 180 |
// Handle unsupported CPUShares |
| 181 | 181 |
if hostConfig.CPUShares < linuxMinCPUShares {
|
| ... | ... |
@@ -209,7 +210,7 @@ func (daemon *Daemon) adaptContainerSettings(hostConfig *runconfig.HostConfig, a |
| 209 | 209 |
return nil |
| 210 | 210 |
} |
| 211 | 211 |
|
| 212 |
-func verifyContainerResources(resources *runconfig.Resources) ([]string, error) {
|
|
| 212 |
+func verifyContainerResources(resources *containertypes.Resources) ([]string, error) {
|
|
| 213 | 213 |
warnings := []string{}
|
| 214 | 214 |
sysInfo := sysinfo.New(true) |
| 215 | 215 |
|
| ... | ... |
@@ -349,7 +350,7 @@ func verifyContainerResources(resources *runconfig.Resources) ([]string, error) |
| 349 | 349 |
|
| 350 | 350 |
// verifyPlatformContainerSettings performs platform-specific validation of the |
| 351 | 351 |
// hostconfig and config structures. |
| 352 |
-func verifyPlatformContainerSettings(daemon *Daemon, hostConfig *runconfig.HostConfig, config *runconfig.Config) ([]string, error) {
|
|
| 352 |
+func verifyPlatformContainerSettings(daemon *Daemon, hostConfig *containertypes.HostConfig, config *containertypes.Config) ([]string, error) {
|
|
| 353 | 353 |
warnings := []string{}
|
| 354 | 354 |
sysInfo := sysinfo.New(true) |
| 355 | 355 |
|
| ... | ... |
@@ -680,7 +681,7 @@ func setupInitLayer(initLayer string, rootUID, rootGID int) error {
|
| 680 | 680 |
} |
| 681 | 681 |
|
| 682 | 682 |
// registerLinks writes the links to a file. |
| 683 |
-func (daemon *Daemon) registerLinks(container *container.Container, hostConfig *runconfig.HostConfig) error {
|
|
| 683 |
+func (daemon *Daemon) registerLinks(container *container.Container, hostConfig *containertypes.HostConfig) error {
|
|
| 684 | 684 |
if hostConfig == nil || hostConfig.Links == nil {
|
| 685 | 685 |
return nil |
| 686 | 686 |
} |
| ... | ... |
@@ -7,7 +7,7 @@ import ( |
| 7 | 7 |
"os" |
| 8 | 8 |
"testing" |
| 9 | 9 |
|
| 10 |
- "github.com/docker/docker/runconfig" |
|
| 10 |
+ "github.com/docker/docker/api/types/container" |
|
| 11 | 11 |
) |
| 12 | 12 |
|
| 13 | 13 |
func TestAdjustCPUShares(t *testing.T) {
|
| ... | ... |
@@ -21,8 +21,8 @@ func TestAdjustCPUShares(t *testing.T) {
|
| 21 | 21 |
root: tmp, |
| 22 | 22 |
} |
| 23 | 23 |
|
| 24 |
- hostConfig := &runconfig.HostConfig{
|
|
| 25 |
- Resources: runconfig.Resources{CPUShares: linuxMinCPUShares - 1},
|
|
| 24 |
+ hostConfig := &container.HostConfig{
|
|
| 25 |
+ Resources: container.Resources{CPUShares: linuxMinCPUShares - 1},
|
|
| 26 | 26 |
} |
| 27 | 27 |
daemon.adaptContainerSettings(hostConfig, true) |
| 28 | 28 |
if hostConfig.CPUShares != linuxMinCPUShares {
|
| ... | ... |
@@ -59,8 +59,8 @@ func TestAdjustCPUSharesNoAdjustment(t *testing.T) {
|
| 59 | 59 |
root: tmp, |
| 60 | 60 |
} |
| 61 | 61 |
|
| 62 |
- hostConfig := &runconfig.HostConfig{
|
|
| 63 |
- Resources: runconfig.Resources{CPUShares: linuxMinCPUShares - 1},
|
|
| 62 |
+ hostConfig := &container.HostConfig{
|
|
| 63 |
+ Resources: container.Resources{CPUShares: linuxMinCPUShares - 1},
|
|
| 64 | 64 |
} |
| 65 | 65 |
daemon.adaptContainerSettings(hostConfig, false) |
| 66 | 66 |
if hostConfig.CPUShares != linuxMinCPUShares-1 {
|
| ... | ... |
@@ -9,6 +9,7 @@ import ( |
| 9 | 9 |
"strings" |
| 10 | 10 |
|
| 11 | 11 |
"github.com/Sirupsen/logrus" |
| 12 |
+ containertypes "github.com/docker/docker/api/types/container" |
|
| 12 | 13 |
"github.com/docker/docker/container" |
| 13 | 14 |
"github.com/docker/docker/daemon/graphdriver" |
| 14 | 15 |
"github.com/docker/docker/dockerversion" |
| ... | ... |
@@ -18,7 +19,6 @@ import ( |
| 18 | 18 |
// register the windows graph driver |
| 19 | 19 |
"github.com/docker/docker/daemon/graphdriver/windows" |
| 20 | 20 |
"github.com/docker/docker/pkg/system" |
| 21 |
- "github.com/docker/docker/runconfig" |
|
| 22 | 21 |
"github.com/docker/libnetwork" |
| 23 | 22 |
blkiodev "github.com/opencontainers/runc/libcontainer/configs" |
| 24 | 23 |
) |
| ... | ... |
@@ -30,27 +30,27 @@ const ( |
| 30 | 30 |
windowsMaxCPUShares = 10000 |
| 31 | 31 |
) |
| 32 | 32 |
|
| 33 |
-func getBlkioWeightDevices(config *runconfig.HostConfig) ([]*blkiodev.WeightDevice, error) {
|
|
| 33 |
+func getBlkioWeightDevices(config *containertypes.HostConfig) ([]*blkiodev.WeightDevice, error) {
|
|
| 34 | 34 |
return nil, nil |
| 35 | 35 |
} |
| 36 | 36 |
|
| 37 |
-func parseSecurityOpt(container *container.Container, config *runconfig.HostConfig) error {
|
|
| 37 |
+func parseSecurityOpt(container *container.Container, config *containertypes.HostConfig) error {
|
|
| 38 | 38 |
return nil |
| 39 | 39 |
} |
| 40 | 40 |
|
| 41 |
-func getBlkioReadIOpsDevices(config *runconfig.HostConfig) ([]*blkiodev.ThrottleDevice, error) {
|
|
| 41 |
+func getBlkioReadIOpsDevices(config *containertypes.HostConfig) ([]*blkiodev.ThrottleDevice, error) {
|
|
| 42 | 42 |
return nil, nil |
| 43 | 43 |
} |
| 44 | 44 |
|
| 45 |
-func getBlkioWriteIOpsDevices(config *runconfig.HostConfig) ([]*blkiodev.ThrottleDevice, error) {
|
|
| 45 |
+func getBlkioWriteIOpsDevices(config *containertypes.HostConfig) ([]*blkiodev.ThrottleDevice, error) {
|
|
| 46 | 46 |
return nil, nil |
| 47 | 47 |
} |
| 48 | 48 |
|
| 49 |
-func getBlkioReadBpsDevices(config *runconfig.HostConfig) ([]*blkiodev.ThrottleDevice, error) {
|
|
| 49 |
+func getBlkioReadBpsDevices(config *containertypes.HostConfig) ([]*blkiodev.ThrottleDevice, error) {
|
|
| 50 | 50 |
return nil, nil |
| 51 | 51 |
} |
| 52 | 52 |
|
| 53 |
-func getBlkioWriteBpsDevices(config *runconfig.HostConfig) ([]*blkiodev.ThrottleDevice, error) {
|
|
| 53 |
+func getBlkioWriteBpsDevices(config *containertypes.HostConfig) ([]*blkiodev.ThrottleDevice, error) {
|
|
| 54 | 54 |
return nil, nil |
| 55 | 55 |
} |
| 56 | 56 |
|
| ... | ... |
@@ -64,7 +64,7 @@ func checkKernel() error {
|
| 64 | 64 |
|
| 65 | 65 |
// adaptContainerSettings is called during container creation to modify any |
| 66 | 66 |
// settings necessary in the HostConfig structure. |
| 67 |
-func (daemon *Daemon) adaptContainerSettings(hostConfig *runconfig.HostConfig, adjustCPUShares bool) error {
|
|
| 67 |
+func (daemon *Daemon) adaptContainerSettings(hostConfig *containertypes.HostConfig, adjustCPUShares bool) error {
|
|
| 68 | 68 |
if hostConfig == nil {
|
| 69 | 69 |
return nil |
| 70 | 70 |
} |
| ... | ... |
@@ -82,7 +82,7 @@ func (daemon *Daemon) adaptContainerSettings(hostConfig *runconfig.HostConfig, a |
| 82 | 82 |
|
| 83 | 83 |
// verifyPlatformContainerSettings performs platform-specific validation of the |
| 84 | 84 |
// hostconfig and config structures. |
| 85 |
-func verifyPlatformContainerSettings(daemon *Daemon, hostConfig *runconfig.HostConfig, config *runconfig.Config) ([]string, error) {
|
|
| 85 |
+func verifyPlatformContainerSettings(daemon *Daemon, hostConfig *containertypes.HostConfig, config *containertypes.Config) ([]string, error) {
|
|
| 86 | 86 |
return nil, nil |
| 87 | 87 |
} |
| 88 | 88 |
|
| ... | ... |
@@ -131,7 +131,7 @@ func (daemon *Daemon) initNetworkController(config *Config) (libnetwork.NetworkC |
| 131 | 131 |
|
| 132 | 132 |
// registerLinks sets up links between containers and writes the |
| 133 | 133 |
// configuration out for persistence. As of Windows TP4, links are not supported. |
| 134 |
-func (daemon *Daemon) registerLinks(container *container.Container, hostConfig *runconfig.HostConfig) error {
|
|
| 134 |
+func (daemon *Daemon) registerLinks(container *container.Container, hostConfig *containertypes.HostConfig) error {
|
|
| 135 | 135 |
return nil |
| 136 | 136 |
} |
| 137 | 137 |
|
| ... | ... |
@@ -11,6 +11,7 @@ import ( |
| 11 | 11 |
"github.com/Sirupsen/logrus" |
| 12 | 12 |
"github.com/docker/docker/api" |
| 13 | 13 |
"github.com/docker/docker/api/types" |
| 14 |
+ "github.com/docker/docker/api/types/container" |
|
| 14 | 15 |
"github.com/docker/docker/builder" |
| 15 | 16 |
"github.com/docker/docker/daemon" |
| 16 | 17 |
"github.com/docker/docker/image" |
| ... | ... |
@@ -21,7 +22,6 @@ import ( |
| 21 | 21 |
"github.com/docker/docker/pkg/urlutil" |
| 22 | 22 |
"github.com/docker/docker/reference" |
| 23 | 23 |
"github.com/docker/docker/registry" |
| 24 |
- "github.com/docker/docker/runconfig" |
|
| 25 | 24 |
) |
| 26 | 25 |
|
| 27 | 26 |
// Docker implements builder.Backend for the docker Daemon object. |
| ... | ... |
@@ -182,7 +182,7 @@ func (d Docker) BuilderCopy(cID string, destPath string, src builder.FileInfo, d |
| 182 | 182 |
|
| 183 | 183 |
// GetCachedImage returns a reference to a cached image whose parent equals `parent` |
| 184 | 184 |
// and runconfig equals `cfg`. A cache miss is expected to return an empty ID and a nil error. |
| 185 |
-func (d Docker) GetCachedImage(imgID string, cfg *runconfig.Config) (string, error) {
|
|
| 185 |
+func (d Docker) GetCachedImage(imgID string, cfg *container.Config) (string, error) {
|
|
| 186 | 186 |
cache, err := d.Daemon.ImageGetCached(image.ID(imgID), cfg) |
| 187 | 187 |
if cache == nil || err != nil {
|
| 188 | 188 |
return "", err |
| ... | ... |
@@ -1,8 +1,8 @@ |
| 1 | 1 |
package daemonbuilder |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 |
+ "github.com/docker/docker/api/types/container" |
|
| 4 | 5 |
"github.com/docker/docker/image" |
| 5 |
- "github.com/docker/docker/runconfig" |
|
| 6 | 6 |
) |
| 7 | 7 |
|
| 8 | 8 |
type imgWrap struct {
|
| ... | ... |
@@ -13,6 +13,6 @@ func (img imgWrap) ID() string {
|
| 13 | 13 |
return string(img.inner.ID()) |
| 14 | 14 |
} |
| 15 | 15 |
|
| 16 |
-func (img imgWrap) Config() *runconfig.Config {
|
|
| 16 |
+func (img imgWrap) Config() *container.Config {
|
|
| 17 | 17 |
return img.inner.Config |
| 18 | 18 |
} |
| ... | ... |
@@ -6,8 +6,8 @@ import ( |
| 6 | 6 |
"testing" |
| 7 | 7 |
|
| 8 | 8 |
"github.com/docker/docker/api/types" |
| 9 |
+ containertypes "github.com/docker/docker/api/types/container" |
|
| 9 | 10 |
"github.com/docker/docker/container" |
| 10 |
- "github.com/docker/docker/runconfig" |
|
| 11 | 11 |
) |
| 12 | 12 |
|
| 13 | 13 |
func TestContainerDoubleDelete(t *testing.T) {
|
| ... | ... |
@@ -26,7 +26,7 @@ func TestContainerDoubleDelete(t *testing.T) {
|
| 26 | 26 |
CommonContainer: container.CommonContainer{
|
| 27 | 27 |
ID: "test", |
| 28 | 28 |
State: container.NewState(), |
| 29 |
- Config: &runconfig.Config{},
|
|
| 29 |
+ Config: &containertypes.Config{},
|
|
| 30 | 30 |
}, |
| 31 | 31 |
} |
| 32 | 32 |
daemon.containers.Add(container.ID, container) |
| ... | ... |
@@ -1,9 +1,6 @@ |
| 1 | 1 |
package execdriver |
| 2 | 2 |
|
| 3 |
-import ( |
|
| 4 |
- "github.com/docker/docker/runconfig" |
|
| 5 |
- "github.com/docker/go-connections/nat" |
|
| 6 |
-) |
|
| 3 |
+import "github.com/docker/go-connections/nat" |
|
| 7 | 4 |
|
| 8 | 5 |
// Mount contains information for a mount operation. |
| 9 | 6 |
type Mount struct {
|
| ... | ... |
@@ -52,12 +49,13 @@ type Command struct {
|
| 52 | 52 |
|
| 53 | 53 |
// Fields below here are platform specific |
| 54 | 54 |
|
| 55 |
- FirstStart bool `json:"first_start"` // Optimisation for first boot of Windows |
|
| 56 |
- Hostname string `json:"hostname"` // Windows sets the hostname in the execdriver |
|
| 57 |
- LayerFolder string `json:"layer_folder"` // Layer folder for a command |
|
| 58 |
- LayerPaths []string `json:"layer_paths"` // Layer paths for a command |
|
| 59 |
- Isolation runconfig.IsolationLevel `json:"isolation"` // Isolation level for the container |
|
| 60 |
- ArgsEscaped bool `json:"args_escaped"` // True if args are already escaped |
|
| 55 |
+ FirstStart bool `json:"first_start"` // Optimisation for first boot of Windows |
|
| 56 |
+ Hostname string `json:"hostname"` // Windows sets the hostname in the execdriver |
|
| 57 |
+ LayerFolder string `json:"layer_folder"` // Layer folder for a command |
|
| 58 |
+ LayerPaths []string `json:"layer_paths"` // Layer paths for a command |
|
| 59 |
+ Isolation string `json:"isolation"` // Isolation level for the container |
|
| 60 |
+ ArgsEscaped bool `json:"args_escaped"` // True if args are already escaped |
|
| 61 |
+ HvPartition bool `json:"hv_partition"` // True if it's an hypervisor partition |
|
| 61 | 62 |
} |
| 62 | 63 |
|
| 63 | 64 |
// ExitStatus provides exit reasons for a container. |
| ... | ... |
@@ -3,14 +3,14 @@ |
| 3 | 3 |
package windows |
| 4 | 4 |
|
| 5 | 5 |
import ( |
| 6 |
+ "github.com/docker/docker/api/types/container" |
|
| 6 | 7 |
"github.com/docker/docker/daemon/execdriver" |
| 7 |
- "github.com/docker/docker/runconfig" |
|
| 8 | 8 |
) |
| 9 | 9 |
|
| 10 | 10 |
type info struct {
|
| 11 | 11 |
ID string |
| 12 | 12 |
driver *Driver |
| 13 |
- isolation runconfig.IsolationLevel |
|
| 13 |
+ isolation container.IsolationLevel |
|
| 14 | 14 |
} |
| 15 | 15 |
|
| 16 | 16 |
// Info implements the exec driver Driver interface. |
| ... | ... |
@@ -18,7 +18,7 @@ func (d *Driver) Info(id string) execdriver.Info {
|
| 18 | 18 |
return &info{
|
| 19 | 19 |
ID: id, |
| 20 | 20 |
driver: d, |
| 21 |
- isolation: defaultIsolation, |
|
| 21 |
+ isolation: DefaultIsolation, |
|
| 22 | 22 |
} |
| 23 | 23 |
} |
| 24 | 24 |
|
| ... | ... |
@@ -104,14 +104,7 @@ func (d *Driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, hooks execd |
| 104 | 104 |
HostName: c.Hostname, |
| 105 | 105 |
} |
| 106 | 106 |
|
| 107 |
- // Work out the isolation (whether it is a hypervisor partition) |
|
| 108 |
- if c.Isolation.IsDefault() {
|
|
| 109 |
- // Not specified by caller. Take daemon default |
|
| 110 |
- cu.HvPartition = defaultIsolation.IsHyperV() |
|
| 111 |
- } else {
|
|
| 112 |
- // Take value specified by caller |
|
| 113 |
- cu.HvPartition = c.Isolation.IsHyperV() |
|
| 114 |
- } |
|
| 107 |
+ cu.HvPartition = c.HvPartition |
|
| 115 | 108 |
|
| 116 | 109 |
if cu.HvPartition {
|
| 117 | 110 |
cu.SandboxPath = filepath.Dir(c.LayerFolder) |
| ... | ... |
@@ -8,10 +8,10 @@ import ( |
| 8 | 8 |
"sync" |
| 9 | 9 |
|
| 10 | 10 |
"github.com/Sirupsen/logrus" |
| 11 |
+ "github.com/docker/docker/api/types/container" |
|
| 11 | 12 |
"github.com/docker/docker/daemon/execdriver" |
| 12 | 13 |
"github.com/docker/docker/dockerversion" |
| 13 | 14 |
"github.com/docker/docker/pkg/parsers" |
| 14 |
- "github.com/docker/docker/runconfig" |
|
| 15 | 15 |
) |
| 16 | 16 |
|
| 17 | 17 |
// This is a daemon development variable only and should not be |
| ... | ... |
@@ -22,11 +22,11 @@ var dummyMode bool |
| 22 | 22 |
// This allows the daemon to force kill (HCS terminate) rather than shutdown |
| 23 | 23 |
var forceKill bool |
| 24 | 24 |
|
| 25 |
-// defaultIsolation allows users to specify a default isolation mode for |
|
| 25 |
+// DefaultIsolation allows users to specify a default isolation mode for |
|
| 26 | 26 |
// when running a container on Windows. For example docker daemon -D |
| 27 | 27 |
// --exec-opt isolation=hyperv will cause Windows to always run containers |
| 28 | 28 |
// as Hyper-V containers unless otherwise specified. |
| 29 |
-var defaultIsolation runconfig.IsolationLevel = "process" |
|
| 29 |
+var DefaultIsolation container.IsolationLevel = "process" |
|
| 30 | 30 |
|
| 31 | 31 |
// Define name and version for windows |
| 32 | 32 |
var ( |
| ... | ... |
@@ -48,7 +48,7 @@ type Driver struct {
|
| 48 | 48 |
|
| 49 | 49 |
// Name implements the exec driver Driver interface. |
| 50 | 50 |
func (d *Driver) Name() string {
|
| 51 |
- return fmt.Sprintf("\n Name: %s\n Build: %s \n Default Isolation: %s", DriverName, Version, defaultIsolation)
|
|
| 51 |
+ return fmt.Sprintf("\n Name: %s\n Build: %s \n Default Isolation: %s", DriverName, Version, DefaultIsolation)
|
|
| 52 | 52 |
} |
| 53 | 53 |
|
| 54 | 54 |
// NewDriver returns a new windows driver, called from NewDriver of execdriver. |
| ... | ... |
@@ -77,11 +77,11 @@ func NewDriver(root string, options []string) (*Driver, error) {
|
| 77 | 77 |
} |
| 78 | 78 |
|
| 79 | 79 |
case "isolation": |
| 80 |
- if !runconfig.IsolationLevel(val).IsValid() {
|
|
| 80 |
+ if !container.IsolationLevel(val).IsValid() {
|
|
| 81 | 81 |
return nil, fmt.Errorf("Unrecognised exec driver option 'isolation':'%s'", val)
|
| 82 | 82 |
} |
| 83 |
- if runconfig.IsolationLevel(val).IsHyperV() {
|
|
| 84 |
- defaultIsolation = "hyperv" |
|
| 83 |
+ if container.IsolationLevel(val).IsHyperV() {
|
|
| 84 |
+ DefaultIsolation = "hyperv" |
|
| 85 | 85 |
} |
| 86 | 86 |
logrus.Infof("Windows default isolation level: '%s'", val)
|
| 87 | 87 |
default: |
| ... | ... |
@@ -8,6 +8,7 @@ import ( |
| 8 | 8 |
"runtime" |
| 9 | 9 |
"time" |
| 10 | 10 |
|
| 11 |
+ "github.com/docker/docker/api/types/container" |
|
| 11 | 12 |
"github.com/docker/docker/dockerversion" |
| 12 | 13 |
"github.com/docker/docker/image" |
| 13 | 14 |
"github.com/docker/docker/layer" |
| ... | ... |
@@ -15,14 +16,13 @@ import ( |
| 15 | 15 |
"github.com/docker/docker/pkg/progress" |
| 16 | 16 |
"github.com/docker/docker/pkg/streamformatter" |
| 17 | 17 |
"github.com/docker/docker/reference" |
| 18 |
- "github.com/docker/docker/runconfig" |
|
| 19 | 18 |
) |
| 20 | 19 |
|
| 21 | 20 |
// ImportImage imports an image, getting the archived layer data either from |
| 22 | 21 |
// inConfig (if src is "-"), or from a URI specified in src. Progress output is |
| 23 | 22 |
// written to outStream. Repository and tag names can optionally be given in |
| 24 | 23 |
// the repo and tag arguments, respectively. |
| 25 |
-func (daemon *Daemon) ImportImage(src string, newRef reference.Named, msg string, inConfig io.ReadCloser, outStream io.Writer, config *runconfig.Config) error {
|
|
| 24 |
+func (daemon *Daemon) ImportImage(src string, newRef reference.Named, msg string, inConfig io.ReadCloser, outStream io.Writer, config *container.Config) error {
|
|
| 26 | 25 |
var ( |
| 27 | 26 |
sf = streamformatter.NewJSONStreamFormatter() |
| 28 | 27 |
archive io.ReadCloser |
| ... | ... |
@@ -4,13 +4,14 @@ import ( |
| 4 | 4 |
"runtime" |
| 5 | 5 |
|
| 6 | 6 |
"github.com/Sirupsen/logrus" |
| 7 |
+ containertypes "github.com/docker/docker/api/types/container" |
|
| 7 | 8 |
"github.com/docker/docker/container" |
| 8 | 9 |
derr "github.com/docker/docker/errors" |
| 9 | 10 |
"github.com/docker/docker/runconfig" |
| 10 | 11 |
) |
| 11 | 12 |
|
| 12 | 13 |
// ContainerStart starts a container. |
| 13 |
-func (daemon *Daemon) ContainerStart(name string, hostConfig *runconfig.HostConfig) error {
|
|
| 14 |
+func (daemon *Daemon) ContainerStart(name string, hostConfig *containertypes.HostConfig) error {
|
|
| 14 | 15 |
container, err := daemon.GetContainer(name) |
| 15 | 16 |
if err != nil {
|
| 16 | 17 |
return err |
| ... | ... |
@@ -7,10 +7,10 @@ import ( |
| 7 | 7 |
"strings" |
| 8 | 8 |
|
| 9 | 9 |
"github.com/docker/docker/api/types" |
| 10 |
+ containertypes "github.com/docker/docker/api/types/container" |
|
| 10 | 11 |
"github.com/docker/docker/container" |
| 11 | 12 |
"github.com/docker/docker/daemon/execdriver" |
| 12 | 13 |
derr "github.com/docker/docker/errors" |
| 13 |
- "github.com/docker/docker/runconfig" |
|
| 14 | 14 |
"github.com/docker/docker/volume" |
| 15 | 15 |
"github.com/opencontainers/runc/libcontainer/label" |
| 16 | 16 |
) |
| ... | ... |
@@ -71,7 +71,7 @@ func (m mounts) parts(i int) int {
|
| 71 | 71 |
// 2. Select the volumes mounted from another containers. Overrides previously configured mount point destination. |
| 72 | 72 |
// 3. Select the bind mounts set by the client. Overrides previously configured mount point destinations. |
| 73 | 73 |
// 4. Cleanup old volumes that are about to be reassigned. |
| 74 |
-func (daemon *Daemon) registerMountPoints(container *container.Container, hostConfig *runconfig.HostConfig) error {
|
|
| 74 |
+func (daemon *Daemon) registerMountPoints(container *container.Container, hostConfig *containertypes.HostConfig) error {
|
|
| 75 | 75 |
binds := map[string]bool{}
|
| 76 | 76 |
mountPoints := map[string]*volume.MountPoint{}
|
| 77 | 77 |
|
| ... | ... |
@@ -7,7 +7,7 @@ import ( |
| 7 | 7 |
"time" |
| 8 | 8 |
|
| 9 | 9 |
"github.com/docker/distribution/digest" |
| 10 |
- "github.com/docker/docker/runconfig" |
|
| 10 |
+ "github.com/docker/docker/api/types/container" |
|
| 11 | 11 |
) |
| 12 | 12 |
|
| 13 | 13 |
// ID is the content-addressable ID of an image. |
| ... | ... |
@@ -30,13 +30,13 @@ type V1Image struct {
|
| 30 | 30 |
// Container is the id of the container used to commit |
| 31 | 31 |
Container string `json:"container,omitempty"` |
| 32 | 32 |
// ContainerConfig is the configuration of the container that is committed into the image |
| 33 |
- ContainerConfig runconfig.Config `json:"container_config,omitempty"` |
|
| 33 |
+ ContainerConfig container.Config `json:"container_config,omitempty"` |
|
| 34 | 34 |
// DockerVersion specifies version on which image is built |
| 35 | 35 |
DockerVersion string `json:"docker_version,omitempty"` |
| 36 | 36 |
// Author of the image |
| 37 | 37 |
Author string `json:"author,omitempty"` |
| 38 | 38 |
// Config is the configuration of the container received from the client |
| 39 |
- Config *runconfig.Config `json:"config,omitempty"` |
|
| 39 |
+ Config *container.Config `json:"config,omitempty"` |
|
| 40 | 40 |
// Architecture is the hardware that the image is build and runs on |
| 41 | 41 |
Architecture string `json:"architecture,omitempty"` |
| 42 | 42 |
// OS is the operating system used to build and run the image |
| ... | ... |
@@ -16,10 +16,10 @@ import ( |
| 16 | 16 |
"time" |
| 17 | 17 |
|
| 18 | 18 |
"github.com/docker/docker/api/types" |
| 19 |
+ containertypes "github.com/docker/docker/api/types/container" |
|
| 19 | 20 |
"github.com/docker/docker/pkg/integration" |
| 20 | 21 |
"github.com/docker/docker/pkg/integration/checker" |
| 21 | 22 |
"github.com/docker/docker/pkg/stringid" |
| 22 |
- "github.com/docker/docker/runconfig" |
|
| 23 | 23 |
"github.com/go-check/check" |
| 24 | 24 |
) |
| 25 | 25 |
|
| ... | ... |
@@ -678,7 +678,7 @@ func UtilCreateNetworkMode(c *check.C, networkMode string) {
|
| 678 | 678 |
|
| 679 | 679 |
var containerJSON types.ContainerJSON |
| 680 | 680 |
c.Assert(json.Unmarshal(body, &containerJSON), checker.IsNil) |
| 681 |
- c.Assert(containerJSON.HostConfig.NetworkMode, checker.Equals, runconfig.NetworkMode(networkMode), check.Commentf("Mismatched NetworkMode"))
|
|
| 681 |
+ c.Assert(containerJSON.HostConfig.NetworkMode, checker.Equals, containertypes.NetworkMode(networkMode), check.Commentf("Mismatched NetworkMode"))
|
|
| 682 | 682 |
} |
| 683 | 683 |
|
| 684 | 684 |
func (s *DockerSuite) TestContainerApiCreateWithCpuSharesCpuset(c *check.C) {
|
| ... | ... |
@@ -9,8 +9,8 @@ import ( |
| 9 | 9 |
"time" |
| 10 | 10 |
|
| 11 | 11 |
"github.com/docker/docker/api/types" |
| 12 |
+ "github.com/docker/docker/api/types/container" |
|
| 12 | 13 |
"github.com/docker/docker/pkg/integration/checker" |
| 13 |
- "github.com/docker/docker/runconfig" |
|
| 14 | 14 |
"github.com/go-check/check" |
| 15 | 15 |
) |
| 16 | 16 |
|
| ... | ... |
@@ -281,7 +281,7 @@ func (s *DockerSuite) TestInspectTimesAsRFC3339Nano(c *check.C) {
|
| 281 | 281 |
func (s *DockerSuite) TestInspectLogConfigNoType(c *check.C) {
|
| 282 | 282 |
testRequires(c, DaemonIsLinux) |
| 283 | 283 |
dockerCmd(c, "create", "--name=test", "--log-opt", "max-file=42", "busybox") |
| 284 |
- var logConfig runconfig.LogConfig |
|
| 284 |
+ var logConfig container.LogConfig |
|
| 285 | 285 |
|
| 286 | 286 |
out, err := inspectFieldJSON("test", "HostConfig.LogConfig")
|
| 287 | 287 |
c.Assert(err, checker.IsNil, check.Commentf("%v", out))
|
| ... | ... |
@@ -1,8 +1,10 @@ |
| 1 | 1 |
package runconfig |
| 2 | 2 |
|
| 3 |
+import "github.com/docker/docker/api/types/container" |
|
| 4 |
+ |
|
| 3 | 5 |
// Compare two Config struct. Do not compare the "Image" nor "Hostname" fields |
| 4 | 6 |
// If OpenStdin is set, then it differs |
| 5 |
-func Compare(a, b *Config) bool {
|
|
| 7 |
+func Compare(a, b *container.Config) bool {
|
|
| 6 | 8 |
if a == nil || b == nil || |
| 7 | 9 |
a.OpenStdin || b.OpenStdin {
|
| 8 | 10 |
return false |
| ... | ... |
@@ -3,6 +3,7 @@ package runconfig |
| 3 | 3 |
import ( |
| 4 | 4 |
"testing" |
| 5 | 5 |
|
| 6 |
+ "github.com/docker/docker/api/types/container" |
|
| 6 | 7 |
"github.com/docker/docker/api/types/strslice" |
| 7 | 8 |
"github.com/docker/go-connections/nat" |
| 8 | 9 |
) |
| ... | ... |
@@ -43,11 +44,11 @@ func TestCompare(t *testing.T) {
|
| 43 | 43 |
labels2 := map[string]string{"LABEL1": "value1", "LABEL2": "value3"}
|
| 44 | 44 |
labels3 := map[string]string{"LABEL1": "value1", "LABEL2": "value2", "LABEL3": "value3"}
|
| 45 | 45 |
|
| 46 |
- sameConfigs := map[*Config]*Config{
|
|
| 46 |
+ sameConfigs := map[*container.Config]*container.Config{
|
|
| 47 | 47 |
// Empty config |
| 48 |
- &Config{}: {},
|
|
| 48 |
+ &container.Config{}: {},
|
|
| 49 | 49 |
// Does not compare hostname, domainname & image |
| 50 |
- &Config{
|
|
| 50 |
+ &container.Config{
|
|
| 51 | 51 |
Hostname: "host1", |
| 52 | 52 |
Domainname: "domain1", |
| 53 | 53 |
Image: "image1", |
| ... | ... |
@@ -59,23 +60,23 @@ func TestCompare(t *testing.T) {
|
| 59 | 59 |
User: "user", |
| 60 | 60 |
}, |
| 61 | 61 |
// only OpenStdin |
| 62 |
- &Config{OpenStdin: false}: {OpenStdin: false},
|
|
| 62 |
+ &container.Config{OpenStdin: false}: {OpenStdin: false},
|
|
| 63 | 63 |
// only env |
| 64 |
- &Config{Env: envs1}: {Env: envs1},
|
|
| 64 |
+ &container.Config{Env: envs1}: {Env: envs1},
|
|
| 65 | 65 |
// only cmd |
| 66 |
- &Config{Cmd: cmd1}: {Cmd: cmd1},
|
|
| 66 |
+ &container.Config{Cmd: cmd1}: {Cmd: cmd1},
|
|
| 67 | 67 |
// only labels |
| 68 |
- &Config{Labels: labels1}: {Labels: labels1},
|
|
| 68 |
+ &container.Config{Labels: labels1}: {Labels: labels1},
|
|
| 69 | 69 |
// only exposedPorts |
| 70 |
- &Config{ExposedPorts: ports1}: {ExposedPorts: ports1},
|
|
| 70 |
+ &container.Config{ExposedPorts: ports1}: {ExposedPorts: ports1},
|
|
| 71 | 71 |
// only entrypoints |
| 72 |
- &Config{Entrypoint: entrypoint1}: {Entrypoint: entrypoint1},
|
|
| 72 |
+ &container.Config{Entrypoint: entrypoint1}: {Entrypoint: entrypoint1},
|
|
| 73 | 73 |
// only volumes |
| 74 |
- &Config{Volumes: volumes1}: {Volumes: volumes1},
|
|
| 74 |
+ &container.Config{Volumes: volumes1}: {Volumes: volumes1},
|
|
| 75 | 75 |
} |
| 76 |
- differentConfigs := map[*Config]*Config{
|
|
| 76 |
+ differentConfigs := map[*container.Config]*container.Config{
|
|
| 77 | 77 |
nil: nil, |
| 78 |
- &Config{
|
|
| 78 |
+ &container.Config{
|
|
| 79 | 79 |
Hostname: "host1", |
| 80 | 80 |
Domainname: "domain1", |
| 81 | 81 |
Image: "image1", |
| ... | ... |
@@ -87,30 +88,30 @@ func TestCompare(t *testing.T) {
|
| 87 | 87 |
User: "user2", |
| 88 | 88 |
}, |
| 89 | 89 |
// only OpenStdin |
| 90 |
- &Config{OpenStdin: false}: {OpenStdin: true},
|
|
| 91 |
- &Config{OpenStdin: true}: {OpenStdin: false},
|
|
| 90 |
+ &container.Config{OpenStdin: false}: {OpenStdin: true},
|
|
| 91 |
+ &container.Config{OpenStdin: true}: {OpenStdin: false},
|
|
| 92 | 92 |
// only env |
| 93 |
- &Config{Env: envs1}: {Env: envs2},
|
|
| 93 |
+ &container.Config{Env: envs1}: {Env: envs2},
|
|
| 94 | 94 |
// only cmd |
| 95 |
- &Config{Cmd: cmd1}: {Cmd: cmd2},
|
|
| 95 |
+ &container.Config{Cmd: cmd1}: {Cmd: cmd2},
|
|
| 96 | 96 |
// not the same number of parts |
| 97 |
- &Config{Cmd: cmd1}: {Cmd: cmd3},
|
|
| 97 |
+ &container.Config{Cmd: cmd1}: {Cmd: cmd3},
|
|
| 98 | 98 |
// only labels |
| 99 |
- &Config{Labels: labels1}: {Labels: labels2},
|
|
| 99 |
+ &container.Config{Labels: labels1}: {Labels: labels2},
|
|
| 100 | 100 |
// not the same number of labels |
| 101 |
- &Config{Labels: labels1}: {Labels: labels3},
|
|
| 101 |
+ &container.Config{Labels: labels1}: {Labels: labels3},
|
|
| 102 | 102 |
// only exposedPorts |
| 103 |
- &Config{ExposedPorts: ports1}: {ExposedPorts: ports2},
|
|
| 103 |
+ &container.Config{ExposedPorts: ports1}: {ExposedPorts: ports2},
|
|
| 104 | 104 |
// not the same number of ports |
| 105 |
- &Config{ExposedPorts: ports1}: {ExposedPorts: ports3},
|
|
| 105 |
+ &container.Config{ExposedPorts: ports1}: {ExposedPorts: ports3},
|
|
| 106 | 106 |
// only entrypoints |
| 107 |
- &Config{Entrypoint: entrypoint1}: {Entrypoint: entrypoint2},
|
|
| 107 |
+ &container.Config{Entrypoint: entrypoint1}: {Entrypoint: entrypoint2},
|
|
| 108 | 108 |
// not the same number of parts |
| 109 |
- &Config{Entrypoint: entrypoint1}: {Entrypoint: entrypoint3},
|
|
| 109 |
+ &container.Config{Entrypoint: entrypoint1}: {Entrypoint: entrypoint3},
|
|
| 110 | 110 |
// only volumes |
| 111 |
- &Config{Volumes: volumes1}: {Volumes: volumes2},
|
|
| 111 |
+ &container.Config{Volumes: volumes1}: {Volumes: volumes2},
|
|
| 112 | 112 |
// not the same number of labels |
| 113 |
- &Config{Volumes: volumes1}: {Volumes: volumes3},
|
|
| 113 |
+ &container.Config{Volumes: volumes1}: {Volumes: volumes3},
|
|
| 114 | 114 |
} |
| 115 | 115 |
for config1, config2 := range sameConfigs {
|
| 116 | 116 |
if !Compare(config1, config2) {
|
| ... | ... |
@@ -5,48 +5,15 @@ import ( |
| 5 | 5 |
"fmt" |
| 6 | 6 |
"io" |
| 7 | 7 |
|
| 8 |
- "github.com/docker/docker/api/types/strslice" |
|
| 8 |
+ "github.com/docker/docker/api/types/container" |
|
| 9 | 9 |
"github.com/docker/docker/volume" |
| 10 |
- "github.com/docker/go-connections/nat" |
|
| 11 | 10 |
) |
| 12 | 11 |
|
| 13 |
-// Config contains the configuration data about a container. |
|
| 14 |
-// It should hold only portable information about the container. |
|
| 15 |
-// Here, "portable" means "independent from the host we are running on". |
|
| 16 |
-// Non-portable information *should* appear in HostConfig. |
|
| 17 |
-// All fields added to this struct must be marked `omitempty` to keep getting |
|
| 18 |
-// predictable hashes from the old `v1Compatibility` configuration. |
|
| 19 |
-type Config struct {
|
|
| 20 |
- Hostname string // Hostname |
|
| 21 |
- Domainname string // Domainname |
|
| 22 |
- User string // User that will run the command(s) inside the container |
|
| 23 |
- AttachStdin bool // Attach the standard input, makes possible user interaction |
|
| 24 |
- AttachStdout bool // Attach the standard output |
|
| 25 |
- AttachStderr bool // Attach the standard error |
|
| 26 |
- ExposedPorts map[nat.Port]struct{} `json:",omitempty"` // List of exposed ports
|
|
| 27 |
- PublishService string `json:",omitempty"` // Name of the network service exposed by the container |
|
| 28 |
- Tty bool // Attach standard streams to a tty, including stdin if it is not closed. |
|
| 29 |
- OpenStdin bool // Open stdin |
|
| 30 |
- StdinOnce bool // If true, close stdin after the 1 attached client disconnects. |
|
| 31 |
- Env []string // List of environment variable to set in the container |
|
| 32 |
- Cmd *strslice.StrSlice // Command to run when starting the container |
|
| 33 |
- ArgsEscaped bool `json:",omitempty"` // True if command is already escaped (Windows specific) |
|
| 34 |
- Image string // Name of the image as it was passed by the operator (eg. could be symbolic) |
|
| 35 |
- Volumes map[string]struct{} // List of volumes (mounts) used for the container
|
|
| 36 |
- WorkingDir string // Current directory (PWD) in the command will be launched |
|
| 37 |
- Entrypoint *strslice.StrSlice // Entrypoint to run when starting the container |
|
| 38 |
- NetworkDisabled bool `json:",omitempty"` // Is network disabled |
|
| 39 |
- MacAddress string `json:",omitempty"` // Mac Address of the container |
|
| 40 |
- OnBuild []string // ONBUILD metadata that were defined on the image Dockerfile |
|
| 41 |
- Labels map[string]string // List of labels set to this container |
|
| 42 |
- StopSignal string `json:",omitempty"` // Signal to stop a container |
|
| 43 |
-} |
|
| 44 |
- |
|
| 45 | 12 |
// DecodeContainerConfig decodes a json encoded config into a ContainerConfigWrapper |
| 46 | 13 |
// struct and returns both a Config and an HostConfig struct |
| 47 | 14 |
// Be aware this function is not checking whether the resulted structs are nil, |
| 48 | 15 |
// it's your business to do so |
| 49 |
-func DecodeContainerConfig(src io.Reader) (*Config, *HostConfig, error) {
|
|
| 16 |
+func DecodeContainerConfig(src io.Reader) (*container.Config, *container.HostConfig, error) {
|
|
| 50 | 17 |
var w ContainerConfigWrapper |
| 51 | 18 |
|
| 52 | 19 |
decoder := json.NewDecoder(src) |
| ... | ... |
@@ -85,7 +52,7 @@ func DecodeContainerConfig(src io.Reader) (*Config, *HostConfig, error) {
|
| 85 | 85 |
|
| 86 | 86 |
// validateVolumesAndBindSettings validates each of the volumes and bind settings |
| 87 | 87 |
// passed by the caller to ensure they are valid. |
| 88 |
-func validateVolumesAndBindSettings(c *Config, hc *HostConfig) error {
|
|
| 88 |
+func validateVolumesAndBindSettings(c *container.Config, hc *container.HostConfig) error {
|
|
| 89 | 89 |
|
| 90 | 90 |
// Ensure all volumes and binds are valid. |
| 91 | 91 |
for spec := range c.Volumes {
|
| ... | ... |
@@ -9,6 +9,7 @@ import ( |
| 9 | 9 |
"strings" |
| 10 | 10 |
"testing" |
| 11 | 11 |
|
| 12 |
+ "github.com/docker/docker/api/types/container" |
|
| 12 | 13 |
"github.com/docker/docker/api/types/strslice" |
| 13 | 14 |
) |
| 14 | 15 |
|
| ... | ... |
@@ -101,16 +102,16 @@ func TestDecodeContainerConfigIsolation(t *testing.T) {
|
| 101 | 101 |
|
| 102 | 102 |
// callDecodeContainerConfigIsolation is a utility function to call |
| 103 | 103 |
// DecodeContainerConfig for validating isolation levels |
| 104 |
-func callDecodeContainerConfigIsolation(isolation string) (*Config, *HostConfig, error) {
|
|
| 104 |
+func callDecodeContainerConfigIsolation(isolation string) (*container.Config, *container.HostConfig, error) {
|
|
| 105 | 105 |
var ( |
| 106 | 106 |
b []byte |
| 107 | 107 |
err error |
| 108 | 108 |
) |
| 109 | 109 |
w := ContainerConfigWrapper{
|
| 110 |
- Config: &Config{},
|
|
| 111 |
- HostConfig: &HostConfig{
|
|
| 110 |
+ Config: &container.Config{},
|
|
| 111 |
+ HostConfig: &container.HostConfig{
|
|
| 112 | 112 |
NetworkMode: "none", |
| 113 |
- Isolation: IsolationLevel(isolation)}, |
|
| 113 |
+ Isolation: container.IsolationLevel(isolation)}, |
|
| 114 | 114 |
} |
| 115 | 115 |
if b, err = json.Marshal(w); err != nil {
|
| 116 | 116 |
return nil, nil, fmt.Errorf("Error on marshal %s", err.Error())
|
| ... | ... |
@@ -2,18 +2,20 @@ |
| 2 | 2 |
|
| 3 | 3 |
package runconfig |
| 4 | 4 |
|
| 5 |
+import "github.com/docker/docker/api/types/container" |
|
| 6 |
+ |
|
| 5 | 7 |
// ContainerConfigWrapper is a Config wrapper that hold the container Config (portable) |
| 6 | 8 |
// and the corresponding HostConfig (non-portable). |
| 7 | 9 |
type ContainerConfigWrapper struct {
|
| 8 |
- *Config |
|
| 9 |
- InnerHostConfig *HostConfig `json:"HostConfig,omitempty"` |
|
| 10 |
- Cpuset string `json:",omitempty"` // Deprecated. Exported for backwards compatibility. |
|
| 11 |
- *HostConfig // Deprecated. Exported to read attributes from json that are not in the inner host config structure. |
|
| 10 |
+ *container.Config |
|
| 11 |
+ InnerHostConfig *container.HostConfig `json:"HostConfig,omitempty"` |
|
| 12 |
+ Cpuset string `json:",omitempty"` // Deprecated. Exported for backwards compatibility. |
|
| 13 |
+ *container.HostConfig // Deprecated. Exported to read attributes from json that are not in the inner host config structure. |
|
| 12 | 14 |
} |
| 13 | 15 |
|
| 14 | 16 |
// getHostConfig gets the HostConfig of the Config. |
| 15 | 17 |
// It's mostly there to handle Deprecated fields of the ContainerConfigWrapper |
| 16 |
-func (w *ContainerConfigWrapper) getHostConfig() *HostConfig {
|
|
| 18 |
+func (w *ContainerConfigWrapper) getHostConfig() *container.HostConfig {
|
|
| 17 | 19 |
hc := w.HostConfig |
| 18 | 20 |
|
| 19 | 21 |
if hc == nil && w.InnerHostConfig != nil {
|
| ... | ... |
@@ -1,13 +1,15 @@ |
| 1 | 1 |
package runconfig |
| 2 | 2 |
|
| 3 |
+import "github.com/docker/docker/api/types/container" |
|
| 4 |
+ |
|
| 3 | 5 |
// ContainerConfigWrapper is a Config wrapper that hold the container Config (portable) |
| 4 | 6 |
// and the corresponding HostConfig (non-portable). |
| 5 | 7 |
type ContainerConfigWrapper struct {
|
| 6 |
- *Config |
|
| 7 |
- HostConfig *HostConfig `json:"HostConfig,omitempty"` |
|
| 8 |
+ *container.Config |
|
| 9 |
+ HostConfig *container.HostConfig `json:"HostConfig,omitempty"` |
|
| 8 | 10 |
} |
| 9 | 11 |
|
| 10 | 12 |
// getHostConfig gets the HostConfig of the Config. |
| 11 |
-func (w *ContainerConfigWrapper) getHostConfig() *HostConfig {
|
|
| 13 |
+func (w *ContainerConfigWrapper) getHostConfig() *container.HostConfig {
|
|
| 12 | 14 |
return w.HostConfig |
| 13 | 15 |
} |
| ... | ... |
@@ -3,240 +3,13 @@ package runconfig |
| 3 | 3 |
import ( |
| 4 | 4 |
"encoding/json" |
| 5 | 5 |
"io" |
| 6 |
- "strings" |
|
| 7 | 6 |
|
| 8 |
- "github.com/docker/docker/api/types/blkiodev" |
|
| 9 |
- "github.com/docker/docker/api/types/strslice" |
|
| 10 |
- "github.com/docker/docker/pkg/ulimit" |
|
| 11 |
- "github.com/docker/go-connections/nat" |
|
| 7 |
+ "github.com/docker/docker/api/types/container" |
|
| 12 | 8 |
) |
| 13 | 9 |
|
| 14 |
-// KeyValuePair is a structure that hold a value for a key. |
|
| 15 |
-type KeyValuePair struct {
|
|
| 16 |
- Key string |
|
| 17 |
- Value string |
|
| 18 |
-} |
|
| 19 |
- |
|
| 20 |
-// NetworkMode represents the container network stack. |
|
| 21 |
-type NetworkMode string |
|
| 22 |
- |
|
| 23 |
-// IsolationLevel represents the isolation level of a container. The supported |
|
| 24 |
-// values are platform specific |
|
| 25 |
-type IsolationLevel string |
|
| 26 |
- |
|
| 27 |
-// IsDefault indicates the default isolation level of a container. On Linux this |
|
| 28 |
-// is the native driver. On Windows, this is a Windows Server Container. |
|
| 29 |
-func (i IsolationLevel) IsDefault() bool {
|
|
| 30 |
- return strings.ToLower(string(i)) == "default" || string(i) == "" |
|
| 31 |
-} |
|
| 32 |
- |
|
| 33 |
-// IpcMode represents the container ipc stack. |
|
| 34 |
-type IpcMode string |
|
| 35 |
- |
|
| 36 |
-// IsPrivate indicates whether the container uses it's private ipc stack. |
|
| 37 |
-func (n IpcMode) IsPrivate() bool {
|
|
| 38 |
- return !(n.IsHost() || n.IsContainer()) |
|
| 39 |
-} |
|
| 40 |
- |
|
| 41 |
-// IsHost indicates whether the container uses the host's ipc stack. |
|
| 42 |
-func (n IpcMode) IsHost() bool {
|
|
| 43 |
- return n == "host" |
|
| 44 |
-} |
|
| 45 |
- |
|
| 46 |
-// IsContainer indicates whether the container uses a container's ipc stack. |
|
| 47 |
-func (n IpcMode) IsContainer() bool {
|
|
| 48 |
- parts := strings.SplitN(string(n), ":", 2) |
|
| 49 |
- return len(parts) > 1 && parts[0] == "container" |
|
| 50 |
-} |
|
| 51 |
- |
|
| 52 |
-// Valid indicates whether the ipc stack is valid. |
|
| 53 |
-func (n IpcMode) Valid() bool {
|
|
| 54 |
- parts := strings.Split(string(n), ":") |
|
| 55 |
- switch mode := parts[0]; mode {
|
|
| 56 |
- case "", "host": |
|
| 57 |
- case "container": |
|
| 58 |
- if len(parts) != 2 || parts[1] == "" {
|
|
| 59 |
- return false |
|
| 60 |
- } |
|
| 61 |
- default: |
|
| 62 |
- return false |
|
| 63 |
- } |
|
| 64 |
- return true |
|
| 65 |
-} |
|
| 66 |
- |
|
| 67 |
-// Container returns the name of the container ipc stack is going to be used. |
|
| 68 |
-func (n IpcMode) Container() string {
|
|
| 69 |
- parts := strings.SplitN(string(n), ":", 2) |
|
| 70 |
- if len(parts) > 1 {
|
|
| 71 |
- return parts[1] |
|
| 72 |
- } |
|
| 73 |
- return "" |
|
| 74 |
-} |
|
| 75 |
- |
|
| 76 |
-// UTSMode represents the UTS namespace of the container. |
|
| 77 |
-type UTSMode string |
|
| 78 |
- |
|
| 79 |
-// IsPrivate indicates whether the container uses it's private UTS namespace. |
|
| 80 |
-func (n UTSMode) IsPrivate() bool {
|
|
| 81 |
- return !(n.IsHost()) |
|
| 82 |
-} |
|
| 83 |
- |
|
| 84 |
-// IsHost indicates whether the container uses the host's UTS namespace. |
|
| 85 |
-func (n UTSMode) IsHost() bool {
|
|
| 86 |
- return n == "host" |
|
| 87 |
-} |
|
| 88 |
- |
|
| 89 |
-// Valid indicates whether the UTS namespace is valid. |
|
| 90 |
-func (n UTSMode) Valid() bool {
|
|
| 91 |
- parts := strings.Split(string(n), ":") |
|
| 92 |
- switch mode := parts[0]; mode {
|
|
| 93 |
- case "", "host": |
|
| 94 |
- default: |
|
| 95 |
- return false |
|
| 96 |
- } |
|
| 97 |
- return true |
|
| 98 |
-} |
|
| 99 |
- |
|
| 100 |
-// PidMode represents the pid stack of the container. |
|
| 101 |
-type PidMode string |
|
| 102 |
- |
|
| 103 |
-// IsPrivate indicates whether the container uses it's private pid stack. |
|
| 104 |
-func (n PidMode) IsPrivate() bool {
|
|
| 105 |
- return !(n.IsHost()) |
|
| 106 |
-} |
|
| 107 |
- |
|
| 108 |
-// IsHost indicates whether the container uses the host's pid stack. |
|
| 109 |
-func (n PidMode) IsHost() bool {
|
|
| 110 |
- return n == "host" |
|
| 111 |
-} |
|
| 112 |
- |
|
| 113 |
-// Valid indicates whether the pid stack is valid. |
|
| 114 |
-func (n PidMode) Valid() bool {
|
|
| 115 |
- parts := strings.Split(string(n), ":") |
|
| 116 |
- switch mode := parts[0]; mode {
|
|
| 117 |
- case "", "host": |
|
| 118 |
- default: |
|
| 119 |
- return false |
|
| 120 |
- } |
|
| 121 |
- return true |
|
| 122 |
-} |
|
| 123 |
- |
|
| 124 |
-// DeviceMapping represents the device mapping between the host and the container. |
|
| 125 |
-type DeviceMapping struct {
|
|
| 126 |
- PathOnHost string |
|
| 127 |
- PathInContainer string |
|
| 128 |
- CgroupPermissions string |
|
| 129 |
-} |
|
| 130 |
- |
|
| 131 |
-// RestartPolicy represents the restart policies of the container. |
|
| 132 |
-type RestartPolicy struct {
|
|
| 133 |
- Name string |
|
| 134 |
- MaximumRetryCount int |
|
| 135 |
-} |
|
| 136 |
- |
|
| 137 |
-// IsNone indicates whether the container has the "no" restart policy. |
|
| 138 |
-// This means the container will not automatically restart when exiting. |
|
| 139 |
-func (rp *RestartPolicy) IsNone() bool {
|
|
| 140 |
- return rp.Name == "no" |
|
| 141 |
-} |
|
| 142 |
- |
|
| 143 |
-// IsAlways indicates whether the container has the "always" restart policy. |
|
| 144 |
-// This means the container will automatically restart regardless of the exit status. |
|
| 145 |
-func (rp *RestartPolicy) IsAlways() bool {
|
|
| 146 |
- return rp.Name == "always" |
|
| 147 |
-} |
|
| 148 |
- |
|
| 149 |
-// IsOnFailure indicates whether the container has the "on-failure" restart policy. |
|
| 150 |
-// This means the contain will automatically restart of exiting with a non-zero exit status. |
|
| 151 |
-func (rp *RestartPolicy) IsOnFailure() bool {
|
|
| 152 |
- return rp.Name == "on-failure" |
|
| 153 |
-} |
|
| 154 |
- |
|
| 155 |
-// IsUnlessStopped indicates whether the container has the |
|
| 156 |
-// "unless-stopped" restart policy. This means the container will |
|
| 157 |
-// automatically restart unless user has put it to stopped state. |
|
| 158 |
-func (rp *RestartPolicy) IsUnlessStopped() bool {
|
|
| 159 |
- return rp.Name == "unless-stopped" |
|
| 160 |
-} |
|
| 161 |
- |
|
| 162 |
-// LogConfig represents the logging configuration of the container. |
|
| 163 |
-type LogConfig struct {
|
|
| 164 |
- Type string |
|
| 165 |
- Config map[string]string |
|
| 166 |
-} |
|
| 167 |
- |
|
| 168 |
-// Resources contains container's resources (cgroups config, ulimits...) |
|
| 169 |
-type Resources struct {
|
|
| 170 |
- // Applicable to all platforms |
|
| 171 |
- CPUShares int64 `json:"CpuShares"` // CPU shares (relative weight vs. other containers) |
|
| 172 |
- |
|
| 173 |
- // Applicable to UNIX platforms |
|
| 174 |
- CgroupParent string // Parent cgroup. |
|
| 175 |
- BlkioWeight uint16 // Block IO weight (relative weight vs. other containers) |
|
| 176 |
- BlkioWeightDevice []*blkiodev.WeightDevice |
|
| 177 |
- BlkioDeviceReadBps []*blkiodev.ThrottleDevice |
|
| 178 |
- BlkioDeviceWriteBps []*blkiodev.ThrottleDevice |
|
| 179 |
- BlkioDeviceReadIOps []*blkiodev.ThrottleDevice |
|
| 180 |
- BlkioDeviceWriteIOps []*blkiodev.ThrottleDevice |
|
| 181 |
- CPUPeriod int64 `json:"CpuPeriod"` // CPU CFS (Completely Fair Scheduler) period |
|
| 182 |
- CPUQuota int64 `json:"CpuQuota"` // CPU CFS (Completely Fair Scheduler) quota |
|
| 183 |
- CpusetCpus string // CpusetCpus 0-2, 0,1 |
|
| 184 |
- CpusetMems string // CpusetMems 0-2, 0,1 |
|
| 185 |
- Devices []DeviceMapping // List of devices to map inside the container |
|
| 186 |
- KernelMemory int64 // Kernel memory limit (in bytes) |
|
| 187 |
- Memory int64 // Memory limit (in bytes) |
|
| 188 |
- MemoryReservation int64 // Memory soft limit (in bytes) |
|
| 189 |
- MemorySwap int64 // Total memory usage (memory + swap); set `-1` to disable swap |
|
| 190 |
- MemorySwappiness *int64 // Tuning container memory swappiness behaviour |
|
| 191 |
- OomKillDisable bool // Whether to disable OOM Killer or not |
|
| 192 |
- Ulimits []*ulimit.Ulimit // List of ulimits to be set in the container |
|
| 193 |
-} |
|
| 194 |
- |
|
| 195 |
-// HostConfig the non-portable Config structure of a container. |
|
| 196 |
-// Here, "non-portable" means "dependent of the host we are running on". |
|
| 197 |
-// Portable information *should* appear in Config. |
|
| 198 |
-type HostConfig struct {
|
|
| 199 |
- // Applicable to all platforms |
|
| 200 |
- Binds []string // List of volume bindings for this container |
|
| 201 |
- ContainerIDFile string // File (path) where the containerId is written |
|
| 202 |
- LogConfig LogConfig // Configuration of the logs for this container |
|
| 203 |
- NetworkMode NetworkMode // Network mode to use for the container |
|
| 204 |
- PortBindings nat.PortMap // Port mapping between the exposed port (container) and the host |
|
| 205 |
- RestartPolicy RestartPolicy // Restart policy to be used for the container |
|
| 206 |
- VolumeDriver string // Name of the volume driver used to mount volumes |
|
| 207 |
- VolumesFrom []string // List of volumes to take from other container |
|
| 208 |
- |
|
| 209 |
- // Applicable to UNIX platforms |
|
| 210 |
- CapAdd *strslice.StrSlice // List of kernel capabilities to add to the container |
|
| 211 |
- CapDrop *strslice.StrSlice // List of kernel capabilities to remove from the container |
|
| 212 |
- DNS []string `json:"Dns"` // List of DNS server to lookup |
|
| 213 |
- DNSOptions []string `json:"DnsOptions"` // List of DNSOption to look for |
|
| 214 |
- DNSSearch []string `json:"DnsSearch"` // List of DNSSearch to look for |
|
| 215 |
- ExtraHosts []string // List of extra hosts |
|
| 216 |
- GroupAdd []string // List of additional groups that the container process will run as |
|
| 217 |
- IpcMode IpcMode // IPC namespace to use for the container |
|
| 218 |
- Links []string // List of links (in the name:alias form) |
|
| 219 |
- OomScoreAdj int // Container preference for OOM-killing |
|
| 220 |
- PidMode PidMode // PID namespace to use for the container |
|
| 221 |
- Privileged bool // Is the container in privileged mode |
|
| 222 |
- PublishAllPorts bool // Should docker publish all exposed port for the container |
|
| 223 |
- ReadonlyRootfs bool // Is the container root filesystem in read-only |
|
| 224 |
- SecurityOpt []string // List of string values to customize labels for MLS systems, such as SELinux. |
|
| 225 |
- Tmpfs map[string]string `json:",omitempty"` // List of tmpfs (mounts) used for the container |
|
| 226 |
- UTSMode UTSMode // UTS namespace to use for the container |
|
| 227 |
- ShmSize *int64 // Total shm memory usage |
|
| 228 |
- |
|
| 229 |
- // Applicable to Windows |
|
| 230 |
- ConsoleSize [2]int // Initial console size |
|
| 231 |
- Isolation IsolationLevel // Isolation level of the container (eg default, hyperv) |
|
| 232 |
- |
|
| 233 |
- // Contains container's resources (cgroups, ulimits) |
|
| 234 |
- Resources |
|
| 235 |
-} |
|
| 236 |
- |
|
| 237 | 10 |
// DecodeHostConfig creates a HostConfig based on the specified Reader. |
| 238 | 11 |
// It assumes the content of the reader will be JSON, and decodes it. |
| 239 |
-func DecodeHostConfig(src io.Reader) (*HostConfig, error) {
|
|
| 12 |
+func DecodeHostConfig(src io.Reader) (*container.HostConfig, error) {
|
|
| 240 | 13 |
decoder := json.NewDecoder(src) |
| 241 | 14 |
|
| 242 | 15 |
var w ContainerConfigWrapper |
| ... | ... |
@@ -252,10 +25,10 @@ func DecodeHostConfig(src io.Reader) (*HostConfig, error) {
|
| 252 | 252 |
// to default if it is not populated. This ensures backwards compatibility after |
| 253 | 253 |
// the validation of the network mode was moved from the docker CLI to the |
| 254 | 254 |
// docker daemon. |
| 255 |
-func SetDefaultNetModeIfBlank(hc *HostConfig) *HostConfig {
|
|
| 255 |
+func SetDefaultNetModeIfBlank(hc *container.HostConfig) *container.HostConfig {
|
|
| 256 | 256 |
if hc != nil {
|
| 257 |
- if hc.NetworkMode == NetworkMode("") {
|
|
| 258 |
- hc.NetworkMode = NetworkMode("default")
|
|
| 257 |
+ if hc.NetworkMode == container.NetworkMode("") {
|
|
| 258 |
+ hc.NetworkMode = container.NetworkMode("default")
|
|
| 259 | 259 |
} |
| 260 | 260 |
} |
| 261 | 261 |
return hc |
| ... | ... |
@@ -7,11 +7,13 @@ import ( |
| 7 | 7 |
"fmt" |
| 8 | 8 |
"io/ioutil" |
| 9 | 9 |
"testing" |
| 10 |
+ |
|
| 11 |
+ "github.com/docker/docker/api/types/container" |
|
| 10 | 12 |
) |
| 11 | 13 |
|
| 12 | 14 |
// TODO Windows: This will need addressing for a Windows daemon. |
| 13 | 15 |
func TestNetworkModeTest(t *testing.T) {
|
| 14 |
- networkModes := map[NetworkMode][]bool{
|
|
| 16 |
+ networkModes := map[container.NetworkMode][]bool{
|
|
| 15 | 17 |
// private, bridge, host, container, none, default |
| 16 | 18 |
"": {true, false, false, false, false, false},
|
| 17 | 19 |
"something:weird": {true, false, false, false, false, false},
|
| ... | ... |
@@ -22,7 +24,7 @@ func TestNetworkModeTest(t *testing.T) {
|
| 22 | 22 |
"none": {true, false, false, false, true, false},
|
| 23 | 23 |
"default": {true, false, false, false, false, true},
|
| 24 | 24 |
} |
| 25 |
- networkModeNames := map[NetworkMode]string{
|
|
| 25 |
+ networkModeNames := map[container.NetworkMode]string{
|
|
| 26 | 26 |
"": "", |
| 27 | 27 |
"something:weird": "something:weird", |
| 28 | 28 |
"bridge": "bridge", |
| ... | ... |
@@ -58,7 +60,7 @@ func TestNetworkModeTest(t *testing.T) {
|
| 58 | 58 |
} |
| 59 | 59 |
|
| 60 | 60 |
func TestIpcModeTest(t *testing.T) {
|
| 61 |
- ipcModes := map[IpcMode][]bool{
|
|
| 61 |
+ ipcModes := map[container.IpcMode][]bool{
|
|
| 62 | 62 |
// private, host, container, valid |
| 63 | 63 |
"": {true, false, false, true},
|
| 64 | 64 |
"something:weird": {true, false, false, false},
|
| ... | ... |
@@ -82,7 +84,7 @@ func TestIpcModeTest(t *testing.T) {
|
| 82 | 82 |
t.Fatalf("IpcMode.Valid for %v should have been %v but was %v", ipcMode, state[3], ipcMode.Valid())
|
| 83 | 83 |
} |
| 84 | 84 |
} |
| 85 |
- containerIpcModes := map[IpcMode]string{
|
|
| 85 |
+ containerIpcModes := map[container.IpcMode]string{
|
|
| 86 | 86 |
"": "", |
| 87 | 87 |
"something": "", |
| 88 | 88 |
"something:weird": "weird", |
| ... | ... |
@@ -99,7 +101,7 @@ func TestIpcModeTest(t *testing.T) {
|
| 99 | 99 |
} |
| 100 | 100 |
|
| 101 | 101 |
func TestUTSModeTest(t *testing.T) {
|
| 102 |
- utsModes := map[UTSMode][]bool{
|
|
| 102 |
+ utsModes := map[container.UTSMode][]bool{
|
|
| 103 | 103 |
// private, host, valid |
| 104 | 104 |
"": {true, false, true},
|
| 105 | 105 |
"something:weird": {true, false, false},
|
| ... | ... |
@@ -120,7 +122,7 @@ func TestUTSModeTest(t *testing.T) {
|
| 120 | 120 |
} |
| 121 | 121 |
|
| 122 | 122 |
func TestPidModeTest(t *testing.T) {
|
| 123 |
- pidModes := map[PidMode][]bool{
|
|
| 123 |
+ pidModes := map[container.PidMode][]bool{
|
|
| 124 | 124 |
// private, host, valid |
| 125 | 125 |
"": {true, false, true},
|
| 126 | 126 |
"something:weird": {true, false, false},
|
| ... | ... |
@@ -141,13 +143,13 @@ func TestPidModeTest(t *testing.T) {
|
| 141 | 141 |
} |
| 142 | 142 |
|
| 143 | 143 |
func TestRestartPolicy(t *testing.T) {
|
| 144 |
- restartPolicies := map[RestartPolicy][]bool{
|
|
| 144 |
+ restartPolicies := map[container.RestartPolicy][]bool{
|
|
| 145 | 145 |
// none, always, failure |
| 146 |
- RestartPolicy{}: {false, false, false},
|
|
| 147 |
- RestartPolicy{"something", 0}: {false, false, false},
|
|
| 148 |
- RestartPolicy{"no", 0}: {true, false, false},
|
|
| 149 |
- RestartPolicy{"always", 0}: {false, true, false},
|
|
| 150 |
- RestartPolicy{"on-failure", 0}: {false, false, true},
|
|
| 146 |
+ container.RestartPolicy{}: {false, false, false},
|
|
| 147 |
+ container.RestartPolicy{"something", 0}: {false, false, false},
|
|
| 148 |
+ container.RestartPolicy{"no", 0}: {true, false, false},
|
|
| 149 |
+ container.RestartPolicy{"always", 0}: {false, true, false},
|
|
| 150 |
+ container.RestartPolicy{"on-failure", 0}: {false, false, true},
|
|
| 151 | 151 |
} |
| 152 | 152 |
for restartPolicy, state := range restartPolicies {
|
| 153 | 153 |
if restartPolicy.IsNone() != state[0] {
|
| ... | ... |
@@ -161,28 +163,6 @@ func TestRestartPolicy(t *testing.T) {
|
| 161 | 161 |
} |
| 162 | 162 |
} |
| 163 | 163 |
} |
| 164 |
- |
|
| 165 |
-func TestMergeConfigs(t *testing.T) {
|
|
| 166 |
- expectedHostname := "hostname" |
|
| 167 |
- expectedContainerIDFile := "containerIdFile" |
|
| 168 |
- config := &Config{
|
|
| 169 |
- Hostname: expectedHostname, |
|
| 170 |
- } |
|
| 171 |
- hostConfig := &HostConfig{
|
|
| 172 |
- ContainerIDFile: expectedContainerIDFile, |
|
| 173 |
- } |
|
| 174 |
- containerConfigWrapper := MergeConfigs(config, hostConfig) |
|
| 175 |
- if containerConfigWrapper.Config.Hostname != expectedHostname {
|
|
| 176 |
- t.Fatalf("containerConfigWrapper config hostname expected %v got %v", expectedHostname, containerConfigWrapper.Config.Hostname)
|
|
| 177 |
- } |
|
| 178 |
- if containerConfigWrapper.InnerHostConfig.ContainerIDFile != expectedContainerIDFile {
|
|
| 179 |
- t.Fatalf("containerConfigWrapper hostconfig containerIdfile expected %v got %v", expectedContainerIDFile, containerConfigWrapper.InnerHostConfig.ContainerIDFile)
|
|
| 180 |
- } |
|
| 181 |
- if containerConfigWrapper.Cpuset != "" {
|
|
| 182 |
- t.Fatalf("Expected empty Cpuset, got %v", containerConfigWrapper.Cpuset)
|
|
| 183 |
- } |
|
| 184 |
-} |
|
| 185 |
- |
|
| 186 | 164 |
func TestDecodeHostConfig(t *testing.T) {
|
| 187 | 165 |
fixtures := []struct {
|
| 188 | 166 |
file string |
| ... | ... |
@@ -6,109 +6,25 @@ import ( |
| 6 | 6 |
"fmt" |
| 7 | 7 |
"runtime" |
| 8 | 8 |
"strings" |
| 9 |
-) |
|
| 10 |
- |
|
| 11 |
-// IsValid indicates is an isolation level is valid |
|
| 12 |
-func (i IsolationLevel) IsValid() bool {
|
|
| 13 |
- return i.IsDefault() |
|
| 14 |
-} |
|
| 15 |
- |
|
| 16 |
-// IsPrivate indicates whether container uses it's private network stack. |
|
| 17 |
-func (n NetworkMode) IsPrivate() bool {
|
|
| 18 |
- return !(n.IsHost() || n.IsContainer()) |
|
| 19 |
-} |
|
| 20 | 9 |
|
| 21 |
-// IsDefault indicates whether container uses the default network stack. |
|
| 22 |
-func (n NetworkMode) IsDefault() bool {
|
|
| 23 |
- return n == "default" |
|
| 24 |
-} |
|
| 10 |
+ "github.com/docker/docker/api/types/container" |
|
| 11 |
+) |
|
| 25 | 12 |
|
| 26 | 13 |
// DefaultDaemonNetworkMode returns the default network stack the daemon should |
| 27 | 14 |
// use. |
| 28 |
-func DefaultDaemonNetworkMode() NetworkMode {
|
|
| 29 |
- return NetworkMode("bridge")
|
|
| 30 |
-} |
|
| 31 |
- |
|
| 32 |
-// NetworkName returns the name of the network stack. |
|
| 33 |
-func (n NetworkMode) NetworkName() string {
|
|
| 34 |
- if n.IsBridge() {
|
|
| 35 |
- return "bridge" |
|
| 36 |
- } else if n.IsHost() {
|
|
| 37 |
- return "host" |
|
| 38 |
- } else if n.IsContainer() {
|
|
| 39 |
- return "container" |
|
| 40 |
- } else if n.IsNone() {
|
|
| 41 |
- return "none" |
|
| 42 |
- } else if n.IsDefault() {
|
|
| 43 |
- return "default" |
|
| 44 |
- } else if n.IsUserDefined() {
|
|
| 45 |
- return n.UserDefined() |
|
| 46 |
- } |
|
| 47 |
- return "" |
|
| 48 |
-} |
|
| 49 |
- |
|
| 50 |
-// IsBridge indicates whether container uses the bridge network stack |
|
| 51 |
-func (n NetworkMode) IsBridge() bool {
|
|
| 52 |
- return n == "bridge" |
|
| 53 |
-} |
|
| 54 |
- |
|
| 55 |
-// IsHost indicates whether container uses the host network stack. |
|
| 56 |
-func (n NetworkMode) IsHost() bool {
|
|
| 57 |
- return n == "host" |
|
| 58 |
-} |
|
| 59 |
- |
|
| 60 |
-// IsContainer indicates whether container uses a container network stack. |
|
| 61 |
-func (n NetworkMode) IsContainer() bool {
|
|
| 62 |
- parts := strings.SplitN(string(n), ":", 2) |
|
| 63 |
- return len(parts) > 1 && parts[0] == "container" |
|
| 64 |
-} |
|
| 65 |
- |
|
| 66 |
-// IsNone indicates whether container isn't using a network stack. |
|
| 67 |
-func (n NetworkMode) IsNone() bool {
|
|
| 68 |
- return n == "none" |
|
| 69 |
-} |
|
| 70 |
- |
|
| 71 |
-// ConnectedContainer is the id of the container which network this container is connected to. |
|
| 72 |
-func (n NetworkMode) ConnectedContainer() string {
|
|
| 73 |
- parts := strings.SplitN(string(n), ":", 2) |
|
| 74 |
- if len(parts) > 1 {
|
|
| 75 |
- return parts[1] |
|
| 76 |
- } |
|
| 77 |
- return "" |
|
| 78 |
-} |
|
| 79 |
- |
|
| 80 |
-// IsUserDefined indicates user-created network |
|
| 81 |
-func (n NetworkMode) IsUserDefined() bool {
|
|
| 82 |
- return !n.IsDefault() && !n.IsBridge() && !n.IsHost() && !n.IsNone() && !n.IsContainer() |
|
| 15 |
+func DefaultDaemonNetworkMode() container.NetworkMode {
|
|
| 16 |
+ return container.NetworkMode("bridge")
|
|
| 83 | 17 |
} |
| 84 | 18 |
|
| 85 | 19 |
// IsPreDefinedNetwork indicates if a network is predefined by the daemon |
| 86 | 20 |
func IsPreDefinedNetwork(network string) bool {
|
| 87 |
- n := NetworkMode(network) |
|
| 21 |
+ n := container.NetworkMode(network) |
|
| 88 | 22 |
return n.IsBridge() || n.IsHost() || n.IsNone() |
| 89 | 23 |
} |
| 90 | 24 |
|
| 91 |
-//UserDefined indicates user-created network |
|
| 92 |
-func (n NetworkMode) UserDefined() string {
|
|
| 93 |
- if n.IsUserDefined() {
|
|
| 94 |
- return string(n) |
|
| 95 |
- } |
|
| 96 |
- return "" |
|
| 97 |
-} |
|
| 98 |
- |
|
| 99 |
-// MergeConfigs merges the specified container Config and HostConfig. |
|
| 100 |
-// It creates a ContainerConfigWrapper. |
|
| 101 |
-func MergeConfigs(config *Config, hostConfig *HostConfig) *ContainerConfigWrapper {
|
|
| 102 |
- return &ContainerConfigWrapper{
|
|
| 103 |
- config, |
|
| 104 |
- hostConfig, |
|
| 105 |
- "", nil, |
|
| 106 |
- } |
|
| 107 |
-} |
|
| 108 |
- |
|
| 109 | 25 |
// ValidateNetMode ensures that the various combinations of requested |
| 110 | 26 |
// network settings are valid. |
| 111 |
-func ValidateNetMode(c *Config, hc *HostConfig) error {
|
|
| 27 |
+func ValidateNetMode(c *container.Config, hc *container.HostConfig) error {
|
|
| 112 | 28 |
// We may not be passed a host config, such as in the case of docker commit |
| 113 | 29 |
if hc == nil {
|
| 114 | 30 |
return nil |
| ... | ... |
@@ -161,7 +77,7 @@ func ValidateNetMode(c *Config, hc *HostConfig) error {
|
| 161 | 161 |
// ValidateIsolationLevel performs platform specific validation of the |
| 162 | 162 |
// isolation level in the hostconfig structure. Linux only supports "default" |
| 163 | 163 |
// which is LXC container isolation |
| 164 |
-func ValidateIsolationLevel(hc *HostConfig) error {
|
|
| 164 |
+func ValidateIsolationLevel(hc *container.HostConfig) error {
|
|
| 165 | 165 |
// We may not be passed a host config, such as in the case of docker commit |
| 166 | 166 |
if hc == nil {
|
| 167 | 167 |
return nil |
| ... | ... |
@@ -3,49 +3,14 @@ package runconfig |
| 3 | 3 |
import ( |
| 4 | 4 |
"fmt" |
| 5 | 5 |
"strings" |
| 6 |
-) |
|
| 7 |
- |
|
| 8 |
-// IsDefault indicates whether container uses the default network stack. |
|
| 9 |
-func (n NetworkMode) IsDefault() bool {
|
|
| 10 |
- return n == "default" |
|
| 11 |
-} |
|
| 12 |
- |
|
| 13 |
-// IsHyperV indicates the use of a Hyper-V partition for isolation |
|
| 14 |
-func (i IsolationLevel) IsHyperV() bool {
|
|
| 15 |
- return strings.ToLower(string(i)) == "hyperv" |
|
| 16 |
-} |
|
| 17 |
- |
|
| 18 |
-// IsProcess indicates the use of process isolation |
|
| 19 |
-func (i IsolationLevel) IsProcess() bool {
|
|
| 20 |
- return strings.ToLower(string(i)) == "process" |
|
| 21 |
-} |
|
| 22 | 6 |
|
| 23 |
-// IsValid indicates is an isolation level is valid |
|
| 24 |
-func (i IsolationLevel) IsValid() bool {
|
|
| 25 |
- return i.IsDefault() || i.IsHyperV() || i.IsProcess() |
|
| 26 |
-} |
|
| 7 |
+ "github.com/docker/docker/api/types/container" |
|
| 8 |
+) |
|
| 27 | 9 |
|
| 28 | 10 |
// DefaultDaemonNetworkMode returns the default network stack the daemon should |
| 29 | 11 |
// use. |
| 30 |
-func DefaultDaemonNetworkMode() NetworkMode {
|
|
| 31 |
- return NetworkMode("default")
|
|
| 32 |
-} |
|
| 33 |
- |
|
| 34 |
-// NetworkName returns the name of the network stack. |
|
| 35 |
-func (n NetworkMode) NetworkName() string {
|
|
| 36 |
- if n.IsDefault() {
|
|
| 37 |
- return "default" |
|
| 38 |
- } |
|
| 39 |
- return "" |
|
| 40 |
-} |
|
| 41 |
- |
|
| 42 |
-// MergeConfigs merges the specified container Config and HostConfig. |
|
| 43 |
-// It creates a ContainerConfigWrapper. |
|
| 44 |
-func MergeConfigs(config *Config, hostConfig *HostConfig) *ContainerConfigWrapper {
|
|
| 45 |
- return &ContainerConfigWrapper{
|
|
| 46 |
- config, |
|
| 47 |
- hostConfig, |
|
| 48 |
- } |
|
| 12 |
+func DefaultDaemonNetworkMode() container.NetworkMode {
|
|
| 13 |
+ return container.NetworkMode("default")
|
|
| 49 | 14 |
} |
| 50 | 15 |
|
| 51 | 16 |
// IsPreDefinedNetwork indicates if a network is predefined by the daemon |
| ... | ... |
@@ -55,7 +20,7 @@ func IsPreDefinedNetwork(network string) bool {
|
| 55 | 55 |
|
| 56 | 56 |
// ValidateNetMode ensures that the various combinations of requested |
| 57 | 57 |
// network settings are valid. |
| 58 |
-func ValidateNetMode(c *Config, hc *HostConfig) error {
|
|
| 58 |
+func ValidateNetMode(c *container.Config, hc *container.HostConfig) error {
|
|
| 59 | 59 |
// We may not be passed a host config, such as in the case of docker commit |
| 60 | 60 |
if hc == nil {
|
| 61 | 61 |
return nil |
| ... | ... |
@@ -72,7 +37,7 @@ func ValidateNetMode(c *Config, hc *HostConfig) error {
|
| 72 | 72 |
// ValidateIsolationLevel performs platform specific validation of the |
| 73 | 73 |
// isolation level in the hostconfig structure. Windows supports 'default' (or |
| 74 | 74 |
// blank), 'process', or 'hyperv'. |
| 75 |
-func ValidateIsolationLevel(hc *HostConfig) error {
|
|
| 75 |
+func ValidateIsolationLevel(hc *container.HostConfig) error {
|
|
| 76 | 76 |
// We may not be passed a host config, such as in the case of docker commit |
| 77 | 77 |
if hc == nil {
|
| 78 | 78 |
return nil |
| ... | ... |
@@ -3,6 +3,7 @@ package runconfig |
| 3 | 3 |
import ( |
| 4 | 4 |
"strings" |
| 5 | 5 |
|
| 6 |
+ "github.com/docker/docker/api/types/container" |
|
| 6 | 7 |
"github.com/docker/go-connections/nat" |
| 7 | 8 |
) |
| 8 | 9 |
|
| ... | ... |
@@ -11,7 +12,7 @@ import ( |
| 11 | 11 |
// by the cli. |
| 12 | 12 |
// It will mutate the specified user configuration (userConf) with the image |
| 13 | 13 |
// configuration where the user configuration is incomplete. |
| 14 |
-func Merge(userConf, imageConf *Config) error {
|
|
| 14 |
+func Merge(userConf, imageConf *container.Config) error {
|
|
| 15 | 15 |
if userConf.User == "" {
|
| 16 | 16 |
userConf.User = imageConf.User |
| 17 | 17 |
} |
| ... | ... |
@@ -3,6 +3,7 @@ package runconfig |
| 3 | 3 |
import ( |
| 4 | 4 |
"testing" |
| 5 | 5 |
|
| 6 |
+ "github.com/docker/docker/api/types/container" |
|
| 6 | 7 |
"github.com/docker/go-connections/nat" |
| 7 | 8 |
) |
| 8 | 9 |
|
| ... | ... |
@@ -13,7 +14,7 @@ func TestMerge(t *testing.T) {
|
| 13 | 13 |
portsImage := make(nat.PortSet) |
| 14 | 14 |
portsImage[newPortNoError("tcp", "1111")] = struct{}{}
|
| 15 | 15 |
portsImage[newPortNoError("tcp", "2222")] = struct{}{}
|
| 16 |
- configImage := &Config{
|
|
| 16 |
+ configImage := &container.Config{
|
|
| 17 | 17 |
ExposedPorts: portsImage, |
| 18 | 18 |
Env: []string{"VAR1=1", "VAR2=2"},
|
| 19 | 19 |
Volumes: volumesImage, |
| ... | ... |
@@ -24,7 +25,7 @@ func TestMerge(t *testing.T) {
|
| 24 | 24 |
portsUser[newPortNoError("tcp", "3333")] = struct{}{}
|
| 25 | 25 |
volumesUser := make(map[string]struct{})
|
| 26 | 26 |
volumesUser["/test3"] = struct{}{}
|
| 27 |
- configUser := &Config{
|
|
| 27 |
+ configUser := &container.Config{
|
|
| 28 | 28 |
ExposedPorts: portsUser, |
| 29 | 29 |
Env: []string{"VAR2=3", "VAR3=3"},
|
| 30 | 30 |
Volumes: volumesUser, |
| ... | ... |
@@ -64,7 +65,7 @@ func TestMerge(t *testing.T) {
|
| 64 | 64 |
if err != nil {
|
| 65 | 65 |
t.Error(err) |
| 66 | 66 |
} |
| 67 |
- configImage2 := &Config{
|
|
| 67 |
+ configImage2 := &container.Config{
|
|
| 68 | 68 |
ExposedPorts: ports, |
| 69 | 69 |
} |
| 70 | 70 |
|
| ... | ... |
@@ -6,6 +6,7 @@ import ( |
| 6 | 6 |
"strconv" |
| 7 | 7 |
"strings" |
| 8 | 8 |
|
| 9 |
+ "github.com/docker/docker/api/types/container" |
|
| 9 | 10 |
"github.com/docker/docker/api/types/strslice" |
| 10 | 11 |
"github.com/docker/docker/opts" |
| 11 | 12 |
flag "github.com/docker/docker/pkg/mflag" |
| ... | ... |
@@ -47,7 +48,7 @@ var ( |
| 47 | 47 |
// Parse parses the specified args for the specified command and generates a Config, |
| 48 | 48 |
// a HostConfig and returns them with the specified command. |
| 49 | 49 |
// If the specified args are not valid, it will return an error. |
| 50 |
-func Parse(cmd *flag.FlagSet, args []string) (*Config, *HostConfig, *flag.FlagSet, error) {
|
|
| 50 |
+func Parse(cmd *flag.FlagSet, args []string) (*container.Config, *container.HostConfig, *flag.FlagSet, error) {
|
|
| 51 | 51 |
var ( |
| 52 | 52 |
// FIXME: use utils.ListOpts for attach and volumes? |
| 53 | 53 |
flAttach = opts.NewListOpts(opts.ValidateAttach) |
| ... | ... |
@@ -300,7 +301,7 @@ func Parse(cmd *flag.FlagSet, args []string) (*Config, *HostConfig, *flag.FlagSe |
| 300 | 300 |
} |
| 301 | 301 |
|
| 302 | 302 |
// parse device mappings |
| 303 |
- deviceMappings := []DeviceMapping{}
|
|
| 303 |
+ deviceMappings := []container.DeviceMapping{}
|
|
| 304 | 304 |
for _, device := range flDevices.GetAll() {
|
| 305 | 305 |
deviceMapping, err := ParseDevice(device) |
| 306 | 306 |
if err != nil {
|
| ... | ... |
@@ -321,17 +322,17 @@ func Parse(cmd *flag.FlagSet, args []string) (*Config, *HostConfig, *flag.FlagSe |
| 321 | 321 |
return nil, nil, cmd, err |
| 322 | 322 |
} |
| 323 | 323 |
|
| 324 |
- ipcMode := IpcMode(*flIpcMode) |
|
| 324 |
+ ipcMode := container.IpcMode(*flIpcMode) |
|
| 325 | 325 |
if !ipcMode.Valid() {
|
| 326 | 326 |
return nil, nil, cmd, fmt.Errorf("--ipc: invalid IPC mode")
|
| 327 | 327 |
} |
| 328 | 328 |
|
| 329 |
- pidMode := PidMode(*flPidMode) |
|
| 329 |
+ pidMode := container.PidMode(*flPidMode) |
|
| 330 | 330 |
if !pidMode.Valid() {
|
| 331 | 331 |
return nil, nil, cmd, fmt.Errorf("--pid: invalid PID mode")
|
| 332 | 332 |
} |
| 333 | 333 |
|
| 334 |
- utsMode := UTSMode(*flUTSMode) |
|
| 334 |
+ utsMode := container.UTSMode(*flUTSMode) |
|
| 335 | 335 |
if !utsMode.Valid() {
|
| 336 | 336 |
return nil, nil, cmd, fmt.Errorf("--uts: invalid UTS mode")
|
| 337 | 337 |
} |
| ... | ... |
@@ -346,7 +347,7 @@ func Parse(cmd *flag.FlagSet, args []string) (*Config, *HostConfig, *flag.FlagSe |
| 346 | 346 |
return nil, nil, cmd, err |
| 347 | 347 |
} |
| 348 | 348 |
|
| 349 |
- resources := Resources{
|
|
| 349 |
+ resources := container.Resources{
|
|
| 350 | 350 |
CgroupParent: *flCgroupParent, |
| 351 | 351 |
Memory: flMemory, |
| 352 | 352 |
MemoryReservation: MemoryReservation, |
| ... | ... |
@@ -369,7 +370,7 @@ func Parse(cmd *flag.FlagSet, args []string) (*Config, *HostConfig, *flag.FlagSe |
| 369 | 369 |
Devices: deviceMappings, |
| 370 | 370 |
} |
| 371 | 371 |
|
| 372 |
- config := &Config{
|
|
| 372 |
+ config := &container.Config{
|
|
| 373 | 373 |
Hostname: hostname, |
| 374 | 374 |
Domainname: domainname, |
| 375 | 375 |
ExposedPorts: ports, |
| ... | ... |
@@ -394,7 +395,7 @@ func Parse(cmd *flag.FlagSet, args []string) (*Config, *HostConfig, *flag.FlagSe |
| 394 | 394 |
StopSignal: *flStopSignal, |
| 395 | 395 |
} |
| 396 | 396 |
|
| 397 |
- hostConfig := &HostConfig{
|
|
| 397 |
+ hostConfig := &container.HostConfig{
|
|
| 398 | 398 |
Binds: binds, |
| 399 | 399 |
ContainerIDFile: *flContainerIDFile, |
| 400 | 400 |
OomScoreAdj: *flOomScoreAdj, |
| ... | ... |
@@ -412,7 +413,7 @@ func Parse(cmd *flag.FlagSet, args []string) (*Config, *HostConfig, *flag.FlagSe |
| 412 | 412 |
DNSOptions: flDNSOptions.GetAllOrEmpty(), |
| 413 | 413 |
ExtraHosts: flExtraHosts.GetAll(), |
| 414 | 414 |
VolumesFrom: flVolumesFrom.GetAll(), |
| 415 |
- NetworkMode: NetworkMode(*flNetMode), |
|
| 415 |
+ NetworkMode: container.NetworkMode(*flNetMode), |
|
| 416 | 416 |
IpcMode: ipcMode, |
| 417 | 417 |
PidMode: pidMode, |
| 418 | 418 |
UTSMode: utsMode, |
| ... | ... |
@@ -422,9 +423,9 @@ func Parse(cmd *flag.FlagSet, args []string) (*Config, *HostConfig, *flag.FlagSe |
| 422 | 422 |
RestartPolicy: restartPolicy, |
| 423 | 423 |
SecurityOpt: flSecurityOpt.GetAll(), |
| 424 | 424 |
ReadonlyRootfs: *flReadonlyRootfs, |
| 425 |
- LogConfig: LogConfig{Type: *flLoggingDriver, Config: loggingOpts},
|
|
| 425 |
+ LogConfig: container.LogConfig{Type: *flLoggingDriver, Config: loggingOpts},
|
|
| 426 | 426 |
VolumeDriver: *flVolumeDriver, |
| 427 |
- Isolation: IsolationLevel(*flIsolation), |
|
| 427 |
+ Isolation: container.IsolationLevel(*flIsolation), |
|
| 428 | 428 |
ShmSize: parsedShm, |
| 429 | 429 |
Resources: resources, |
| 430 | 430 |
Tmpfs: tmpfs, |
| ... | ... |
@@ -477,8 +478,8 @@ func parseLoggingOpts(loggingDriver string, loggingOpts []string) (map[string]st |
| 477 | 477 |
} |
| 478 | 478 |
|
| 479 | 479 |
// ParseRestartPolicy returns the parsed policy or an error indicating what is incorrect |
| 480 |
-func ParseRestartPolicy(policy string) (RestartPolicy, error) {
|
|
| 481 |
- p := RestartPolicy{}
|
|
| 480 |
+func ParseRestartPolicy(policy string) (container.RestartPolicy, error) {
|
|
| 481 |
+ p := container.RestartPolicy{}
|
|
| 482 | 482 |
|
| 483 | 483 |
if policy == "" {
|
| 484 | 484 |
return p, nil |
| ... | ... |
@@ -516,20 +517,8 @@ func ParseRestartPolicy(policy string) (RestartPolicy, error) {
|
| 516 | 516 |
return p, nil |
| 517 | 517 |
} |
| 518 | 518 |
|
| 519 |
-func parseKeyValueOpts(opts opts.ListOpts) ([]KeyValuePair, error) {
|
|
| 520 |
- out := make([]KeyValuePair, opts.Len()) |
|
| 521 |
- for i, o := range opts.GetAll() {
|
|
| 522 |
- k, v, err := parsers.ParseKeyValueOpt(o) |
|
| 523 |
- if err != nil {
|
|
| 524 |
- return nil, err |
|
| 525 |
- } |
|
| 526 |
- out[i] = KeyValuePair{Key: k, Value: v}
|
|
| 527 |
- } |
|
| 528 |
- return out, nil |
|
| 529 |
-} |
|
| 530 |
- |
|
| 531 |
-// ParseDevice parses a device mapping string to a DeviceMapping struct |
|
| 532 |
-func ParseDevice(device string) (DeviceMapping, error) {
|
|
| 519 |
+// ParseDevice parses a device mapping string to a container.DeviceMapping struct |
|
| 520 |
+func ParseDevice(device string) (container.DeviceMapping, error) {
|
|
| 533 | 521 |
src := "" |
| 534 | 522 |
dst := "" |
| 535 | 523 |
permissions := "rwm" |
| ... | ... |
@@ -548,14 +537,14 @@ func ParseDevice(device string) (DeviceMapping, error) {
|
| 548 | 548 |
case 1: |
| 549 | 549 |
src = arr[0] |
| 550 | 550 |
default: |
| 551 |
- return DeviceMapping{}, fmt.Errorf("Invalid device specification: %s", device)
|
|
| 551 |
+ return container.DeviceMapping{}, fmt.Errorf("Invalid device specification: %s", device)
|
|
| 552 | 552 |
} |
| 553 | 553 |
|
| 554 | 554 |
if dst == "" {
|
| 555 | 555 |
dst = src |
| 556 | 556 |
} |
| 557 | 557 |
|
| 558 |
- deviceMapping := DeviceMapping{
|
|
| 558 |
+ deviceMapping := container.DeviceMapping{
|
|
| 559 | 559 |
PathOnHost: src, |
| 560 | 560 |
PathInContainer: dst, |
| 561 | 561 |
CgroupPermissions: permissions, |
| ... | ... |
@@ -10,23 +10,24 @@ import ( |
| 10 | 10 |
"strings" |
| 11 | 11 |
"testing" |
| 12 | 12 |
|
| 13 |
+ "github.com/docker/docker/api/types/container" |
|
| 13 | 14 |
flag "github.com/docker/docker/pkg/mflag" |
| 14 | 15 |
"github.com/docker/go-connections/nat" |
| 15 | 16 |
) |
| 16 | 17 |
|
| 17 |
-func parseRun(args []string) (*Config, *HostConfig, *flag.FlagSet, error) {
|
|
| 18 |
+func parseRun(args []string) (*container.Config, *container.HostConfig, *flag.FlagSet, error) {
|
|
| 18 | 19 |
cmd := flag.NewFlagSet("run", flag.ContinueOnError)
|
| 19 | 20 |
cmd.SetOutput(ioutil.Discard) |
| 20 | 21 |
cmd.Usage = nil |
| 21 | 22 |
return Parse(cmd, args) |
| 22 | 23 |
} |
| 23 | 24 |
|
| 24 |
-func parse(t *testing.T, args string) (*Config, *HostConfig, error) {
|
|
| 25 |
+func parse(t *testing.T, args string) (*container.Config, *container.HostConfig, error) {
|
|
| 25 | 26 |
config, hostConfig, _, err := parseRun(strings.Split(args+" ubuntu bash", " ")) |
| 26 | 27 |
return config, hostConfig, err |
| 27 | 28 |
} |
| 28 | 29 |
|
| 29 |
-func mustParse(t *testing.T, args string) (*Config, *HostConfig) {
|
|
| 30 |
+func mustParse(t *testing.T, args string) (*container.Config, *container.HostConfig) {
|
|
| 30 | 31 |
config, hostConfig, err := parse(t, args) |
| 31 | 32 |
if err != nil {
|
| 32 | 33 |
t.Fatal(err) |
| ... | ... |
@@ -280,18 +281,18 @@ func TestDecodeContainerConfigVolumes(t *testing.T) {
|
| 280 | 280 |
// passed into it. It returns a config and a hostconfig which can be |
| 281 | 281 |
// validated to ensure DecodeContainerConfig has manipulated the structures |
| 282 | 282 |
// correctly. |
| 283 |
-func callDecodeContainerConfig(volumes []string, binds []string) (*Config, *HostConfig, error) {
|
|
| 283 |
+func callDecodeContainerConfig(volumes []string, binds []string) (*container.Config, *container.HostConfig, error) {
|
|
| 284 | 284 |
var ( |
| 285 | 285 |
b []byte |
| 286 | 286 |
err error |
| 287 |
- c *Config |
|
| 288 |
- h *HostConfig |
|
| 287 |
+ c *container.Config |
|
| 288 |
+ h *container.HostConfig |
|
| 289 | 289 |
) |
| 290 | 290 |
w := ContainerConfigWrapper{
|
| 291 |
- Config: &Config{
|
|
| 291 |
+ Config: &container.Config{
|
|
| 292 | 292 |
Volumes: map[string]struct{}{},
|
| 293 | 293 |
}, |
| 294 |
- HostConfig: &HostConfig{
|
|
| 294 |
+ HostConfig: &container.HostConfig{
|
|
| 295 | 295 |
NetworkMode: "none", |
| 296 | 296 |
Binds: binds, |
| 297 | 297 |
}, |
| ... | ... |
@@ -450,7 +451,7 @@ func TestParseWithExpose(t *testing.T) {
|
| 450 | 450 |
} |
| 451 | 451 |
|
| 452 | 452 |
func TestParseDevice(t *testing.T) {
|
| 453 |
- valids := map[string]DeviceMapping{
|
|
| 453 |
+ valids := map[string]container.DeviceMapping{
|
|
| 454 | 454 |
"/dev/snd": {
|
| 455 | 455 |
PathOnHost: "/dev/snd", |
| 456 | 456 |
PathInContainer: "/dev/snd", |
| ... | ... |
@@ -546,7 +547,7 @@ func TestParseRestartPolicy(t *testing.T) {
|
| 546 | 546 |
"on-failure:invalid": `strconv.ParseInt: parsing "invalid": invalid syntax`, |
| 547 | 547 |
"on-failure:2:5": "restart count format is not valid, usage: 'on-failure:N' or 'on-failure'", |
| 548 | 548 |
} |
| 549 |
- valids := map[string]RestartPolicy{
|
|
| 549 |
+ valids := map[string]container.RestartPolicy{
|
|
| 550 | 550 |
"": {},
|
| 551 | 551 |
"always": {
|
| 552 | 552 |
Name: "always", |