mirror of https://github.com/docker/cli.git
Add `init` support in 3.7 schema
> Run an init inside the container that forwards signals and reaps processes This is supported on `run` and now on Swarm services too, so it's also possible to have in on a composefile :). Signed-off-by: Vincent Demeester <vincent@sbr.pm>
This commit is contained in:
parent
e529043c51
commit
cc26da94ed
|
@ -150,6 +150,7 @@ func Service(
|
|||
ReadOnly: service.ReadOnly,
|
||||
Privileges: &privileges,
|
||||
Isolation: container.Isolation(service.Isolation),
|
||||
Init: service.Init,
|
||||
},
|
||||
LogDriver: logDriver,
|
||||
Resources: resources,
|
||||
|
|
|
@ -1415,3 +1415,60 @@ networks:
|
|||
}
|
||||
assert.DeepEqual(t, config, expected, cmpopts.EquateEmpty())
|
||||
}
|
||||
|
||||
func TestLoadInit(t *testing.T) {
|
||||
booleanFalse := false
|
||||
booleanTrue := true
|
||||
config, err := loadYAML(`
|
||||
version: '3.7'
|
||||
services:
|
||||
foo:
|
||||
image: alpine`)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.DeepEqual(config, &types.Config{
|
||||
Filename: "filename.yml",
|
||||
Version: "3.7",
|
||||
Services: types.Services{
|
||||
{
|
||||
Name: "foo",
|
||||
Image: "alpine",
|
||||
},
|
||||
},
|
||||
}, cmpopts.EquateEmpty()))
|
||||
config, err = loadYAML(`
|
||||
version: '3.7'
|
||||
services:
|
||||
foo:
|
||||
image: alpine
|
||||
init: true`)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.DeepEqual(config, &types.Config{
|
||||
Filename: "filename.yml",
|
||||
Version: "3.7",
|
||||
Services: types.Services{
|
||||
{
|
||||
Name: "foo",
|
||||
Image: "alpine",
|
||||
Init: &booleanTrue,
|
||||
},
|
||||
},
|
||||
}, cmpopts.EquateEmpty()))
|
||||
config, err = loadYAML(`
|
||||
version: '3.7'
|
||||
services:
|
||||
foo:
|
||||
image: alpine
|
||||
init: false`)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.DeepEqual(config, &types.Config{
|
||||
Filename: "filename.yml",
|
||||
Version: "3.7",
|
||||
Services: types.Services{
|
||||
{
|
||||
Name: "foo",
|
||||
Image: "alpine",
|
||||
Init: &booleanFalse,
|
||||
},
|
||||
},
|
||||
}, cmpopts.EquateEmpty()))
|
||||
}
|
||||
|
|
|
@ -467,7 +467,7 @@ DoTuq9lAU9Q4O1xV/59X/w8AAP//zRo7vm9CAAA=
|
|||
|
||||
"/data/config_schema_v3.7.json": {
|
||||
local: "data/config_schema_v3.7.json",
|
||||
size: 17740,
|
||||
size: 17777,
|
||||
modtime: 1518458244,
|
||||
compressed: `
|
||||
H4sIAAAAAAAC/+xcS4/bOBK++1cYmrlNPwLsYBeb2x73tHvehiPQVNnmNEVyipTTTuD/vtDTEkWKlK1O
|
||||
|
@ -484,27 +484,27 @@ q261wbY83KwjrNLhLgLuJuxwSkuXBdJY/zH3HK3XScGyeOL9HOJcZsN9iyLfAibnEfHokA5+36xcbyzt
|
|||
G8IEYCpIDkE7RshAGEZ4qhXQAXmrqQnNJFH+PEHYM23w5KS8cNHfWAYKRKbTOoKZ73qTDLpwZlE3kYmp
|
||||
K6WeprxUyr0l1sBUA0F6uHK8zAkTMUoFYfCkJKvd2LvzTyCOaWc3s8UA4shQirx10nFXe2/8i5IabneO
|
||||
3UXbMH7XnenNUHrJTmJOys22a688V7DD8voC7PNQQmLCU87E8/ImDi8GSXqQ2lyDnpIDEG4O9AD0eWJ4
|
||||
n2owWmoTY+QsJ/swkaJBEi05MU2mZIrwajiZLKql3rRyvy9JfaY5Ck8igX2G7AgYiz6lukRVris4dO0H
|
||||
w9AB6ZeHOgqdOH7VT5yP4a7rdrWfWBzGAeKBVnJCS9yLoHXIopqoIB2BgwvtiFjHuvSrgpX5QWKU6oKZ
|
||||
hCDk9MHKeCuLg5it2jkjGvRtUV/PCx1/j7QJ19i/T471DPXOGR/jBabqY1nOnRvZhNHta4agaojQh76i
|
||||
8hD9A6Ykmh8SNF381AUZ1IuP4yhb3VGDXif4mvBScaFXm5FwD1DFljN9gG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LNQD4WSf11TQ8obKICc9f36nZ7TfvduKfjbxi9rsq/59X/AwAA//+9o87pcUUAAA==
|
||||
`,
|
||||
},
|
||||
|
||||
|
|
|
@ -154,6 +154,7 @@
|
|||
"healthcheck": {"$ref": "#/definitions/healthcheck"},
|
||||
"hostname": {"type": "string"},
|
||||
"image": {"type": "string"},
|
||||
"init": {"type": "boolean"},
|
||||
"ipc": {"type": "string"},
|
||||
"isolation": {"type": "string"},
|
||||
"labels": {"$ref": "#/definitions/list_or_dict"},
|
||||
|
|
|
@ -119,7 +119,9 @@ type ServiceConfig struct {
|
|||
Hostname string `yaml:",omitempty"`
|
||||
HealthCheck *HealthCheckConfig `yaml:",omitempty"`
|
||||
Image string `yaml:",omitempty"`
|
||||
Init *bool `yaml:",omitempty"`
|
||||
Ipc string `yaml:",omitempty"`
|
||||
Isolation string `mapstructure:"isolation" yaml:"isolation,omitempty"`
|
||||
Labels Labels `yaml:",omitempty"`
|
||||
Links []string `yaml:",omitempty"`
|
||||
Logging *LoggingConfig `yaml:",omitempty"`
|
||||
|
@ -142,8 +144,8 @@ type ServiceConfig struct {
|
|||
User string `yaml:",omitempty"`
|
||||
Volumes []ServiceVolumeConfig `yaml:",omitempty"`
|
||||
WorkingDir string `mapstructure:"working_dir" yaml:"working_dir,omitempty"`
|
||||
Isolation string `mapstructure:"isolation" yaml:"isolation,omitempty"`
|
||||
Extras map[string]interface{} `yaml:",inline"`
|
||||
|
||||
Extras map[string]interface{} `yaml:",inline"`
|
||||
}
|
||||
|
||||
// BuildConfig is a type for build
|
||||
|
|
Loading…
Reference in New Issue