Merge pull request #25637 from tiborvass/cherry-picks-1.12.1
Cherry picks 1.12.1
This commit is contained in:
commit
5dc0715cd2
181 changed files with 5674 additions and 974 deletions
30
CHANGELOG.md
30
CHANGELOG.md
|
@ -7,6 +7,36 @@ be found.
|
|||
|
||||
## 1.12.0 (2016-07-14)
|
||||
|
||||
|
||||
**IMPORTANT**:
|
||||
|
||||
Docker 1.12.0 ships with an updated systemd unit file for rpm based installs
|
||||
(which includes RHEL, Fedora, CentOS, and Oracle Linux 7). When upgrading from
|
||||
an older version of docker, the upgrade process may not automatically install
|
||||
the updated version of the unit file, or fail to start the docker service if;
|
||||
|
||||
- the systemd unit file (`/usr/lib/systemd/system/docker.service`) contains local changes, or
|
||||
- a systemd drop-in file is present, and contains `-H fd://` in the `ExecStart` directive
|
||||
|
||||
Starting the docker service will produce an error:
|
||||
|
||||
Failed to start docker.service: Unit docker.socket failed to load: No such file or directory.
|
||||
|
||||
or
|
||||
|
||||
no sockets found via socket activation: make sure the service was started by systemd.
|
||||
|
||||
To resolve this:
|
||||
|
||||
- Backup the current version of the unit file, and replace the file with the
|
||||
version that ships with docker 1.12 (https://raw.githubusercontent.com/docker/docker/v1.12.0/contrib/init/systemd/docker.service.rpm)
|
||||
- Remove the `Requires=docker.socket` directive from the `/usr/lib/systemd/system/docker.service` file if present
|
||||
- Remove `-H fd://` from the `ExecStart` directive (both in the main unit file, and in any drop-in files present).
|
||||
|
||||
After making those changes, run `sudo systemctl daemon-reload`, and `sudo
|
||||
systemctl restart docker` to reload changes and (re)start the docker daemon.
|
||||
|
||||
|
||||
### Builder
|
||||
|
||||
+ New `HEALTHCHECK` Dockerfile instruction to support user-defined healthchecks [#23218](https://github.com/docker/docker/pull/23218)
|
||||
|
|
2
Makefile
2
Makefile
|
@ -116,7 +116,7 @@ validate: build ## validate DCO, Seccomp profile generation, gofmt,\n./pkg/ isol
|
|||
$(DOCKER_RUN_DOCKER) hack/make.sh validate-dco validate-default-seccomp validate-gofmt validate-pkg validate-lint validate-test validate-toml validate-vet validate-vendor
|
||||
|
||||
manpages: ## Generate man pages from go source and markdown
|
||||
docker build -t docker-manpage-dev -f man/Dockerfile .
|
||||
docker build -t docker-manpage-dev -f "man/$(DOCKERFILE)" ./man
|
||||
docker run \
|
||||
-v $(PWD):/go/src/github.com/docker/docker/ \
|
||||
docker-manpage-dev
|
||||
|
|
|
@ -23,7 +23,7 @@ func NewKillCommand(dockerCli *client.DockerCli) *cobra.Command {
|
|||
|
||||
cmd := &cobra.Command{
|
||||
Use: "kill [OPTIONS] CONTAINER [CONTAINER...]",
|
||||
Short: "Kill one or more running container",
|
||||
Short: "Kill one or more running containers",
|
||||
Args: cli.RequiresMinArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
opts.containers = args
|
||||
|
|
|
@ -42,7 +42,7 @@ func NewPsCommand(dockerCli *client.DockerCli) *cobra.Command {
|
|||
cmd := &cobra.Command{
|
||||
Use: "ps [OPTIONS]",
|
||||
Short: "List containers",
|
||||
Args: cli.ExactArgs(0),
|
||||
Args: cli.NoArgs,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return runPs(dockerCli, &opts)
|
||||
},
|
||||
|
|
|
@ -84,13 +84,19 @@ func (cli *DockerCli) CmdInfo(args ...string) error {
|
|||
fmt.Fprintf(cli.out, " Orchestration:\n")
|
||||
fmt.Fprintf(cli.out, " Task History Retention Limit: %d\n", info.Swarm.Cluster.Spec.Orchestration.TaskHistoryRetentionLimit)
|
||||
fmt.Fprintf(cli.out, " Raft:\n")
|
||||
fmt.Fprintf(cli.out, " Snapshot interval: %d\n", info.Swarm.Cluster.Spec.Raft.SnapshotInterval)
|
||||
fmt.Fprintf(cli.out, " Heartbeat tick: %d\n", info.Swarm.Cluster.Spec.Raft.HeartbeatTick)
|
||||
fmt.Fprintf(cli.out, " Election tick: %d\n", info.Swarm.Cluster.Spec.Raft.ElectionTick)
|
||||
fmt.Fprintf(cli.out, " Snapshot Interval: %d\n", info.Swarm.Cluster.Spec.Raft.SnapshotInterval)
|
||||
fmt.Fprintf(cli.out, " Heartbeat Tick: %d\n", info.Swarm.Cluster.Spec.Raft.HeartbeatTick)
|
||||
fmt.Fprintf(cli.out, " Election Tick: %d\n", info.Swarm.Cluster.Spec.Raft.ElectionTick)
|
||||
fmt.Fprintf(cli.out, " Dispatcher:\n")
|
||||
fmt.Fprintf(cli.out, " Heartbeat period: %s\n", units.HumanDuration(time.Duration(info.Swarm.Cluster.Spec.Dispatcher.HeartbeatPeriod)))
|
||||
fmt.Fprintf(cli.out, " CA configuration:\n")
|
||||
fmt.Fprintf(cli.out, " Expiry duration: %s\n", units.HumanDuration(info.Swarm.Cluster.Spec.CAConfig.NodeCertExpiry))
|
||||
fmt.Fprintf(cli.out, " Heartbeat Period: %s\n", units.HumanDuration(time.Duration(info.Swarm.Cluster.Spec.Dispatcher.HeartbeatPeriod)))
|
||||
fmt.Fprintf(cli.out, " CA Configuration:\n")
|
||||
fmt.Fprintf(cli.out, " Expiry Duration: %s\n", units.HumanDuration(info.Swarm.Cluster.Spec.CAConfig.NodeCertExpiry))
|
||||
if len(info.Swarm.Cluster.Spec.CAConfig.ExternalCAs) > 0 {
|
||||
fmt.Fprintf(cli.out, " External CAs:\n")
|
||||
for _, entry := range info.Swarm.Cluster.Spec.CAConfig.ExternalCAs {
|
||||
fmt.Fprintf(cli.out, " %s: %s\n", entry.Protocol, entry.URL)
|
||||
}
|
||||
}
|
||||
}
|
||||
fmt.Fprintf(cli.out, " Node Address: %s\n", info.Swarm.NodeAddr)
|
||||
}
|
||||
|
|
|
@ -12,9 +12,9 @@ import (
|
|||
|
||||
func newRemoveCommand(dockerCli *client.DockerCli) *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "rm NETWORK [NETWORK]...",
|
||||
Use: "rm NETWORK [NETWORK...]",
|
||||
Aliases: []string{"remove"},
|
||||
Short: "Remove a network",
|
||||
Short: "Remove one or more networks",
|
||||
Args: cli.RequiresMinArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return runRemove(dockerCli, args)
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
func newDemoteCommand(dockerCli *client.DockerCli) *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "demote NODE [NODE...]",
|
||||
Short: "Demote a node from manager in the swarm",
|
||||
Short: "Demote one or more nodes from manager in the swarm",
|
||||
Args: cli.RequiresMinArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return runDemote(dockerCli, args)
|
||||
|
|
|
@ -88,6 +88,7 @@ func printNode(out io.Writer, node swarm.Node) {
|
|||
}
|
||||
|
||||
ioutils.FprintfIfNotEmpty(out, "Hostname:\t\t%s\n", node.Description.Hostname)
|
||||
fmt.Fprintf(out, "Joined at:\t\t%s\n", client.PrettyPrint(node.CreatedAt))
|
||||
fmt.Fprintln(out, "Status:")
|
||||
fmt.Fprintf(out, " State:\t\t\t%s\n", client.PrettyPrint(node.Status.State))
|
||||
ioutils.FprintfIfNotEmpty(out, " Message:\t\t%s\n", client.PrettyPrint(node.Status.Message))
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
func newPromoteCommand(dockerCli *client.DockerCli) *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "promote NODE [NODE...]",
|
||||
Short: "Promote a node to a manager in the swarm",
|
||||
Short: "Promote one or more nodes to manager in the swarm",
|
||||
Args: cli.RequiresMinArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return runPromote(dockerCli, args)
|
||||
|
|
|
@ -7,26 +7,36 @@ import (
|
|||
|
||||
"github.com/docker/docker/api/client"
|
||||
"github.com/docker/docker/cli"
|
||||
"github.com/docker/engine-api/types"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func newRemoveCommand(dockerCli *client.DockerCli) *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "rm NODE [NODE...]",
|
||||
Aliases: []string{"remove"},
|
||||
Short: "Remove a node from the swarm",
|
||||
Args: cli.RequiresMinArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return runRemove(dockerCli, args)
|
||||
},
|
||||
}
|
||||
type removeOptions struct {
|
||||
force bool
|
||||
}
|
||||
|
||||
func runRemove(dockerCli *client.DockerCli, args []string) error {
|
||||
func newRemoveCommand(dockerCli *client.DockerCli) *cobra.Command {
|
||||
opts := removeOptions{}
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: "rm [OPTIONS] NODE [NODE...]",
|
||||
Aliases: []string{"remove"},
|
||||
Short: "Remove one or more nodes from the swarm",
|
||||
Args: cli.RequiresMinArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return runRemove(dockerCli, args, opts)
|
||||
},
|
||||
}
|
||||
flags := cmd.Flags()
|
||||
flags.BoolVar(&opts.force, "force", false, "Force remove an active node")
|
||||
return cmd
|
||||
}
|
||||
|
||||
func runRemove(dockerCli *client.DockerCli, args []string, opts removeOptions) error {
|
||||
client := dockerCli.Client()
|
||||
ctx := context.Background()
|
||||
for _, nodeID := range args {
|
||||
err := client.NodeRemove(ctx, nodeID)
|
||||
err := client.NodeRemove(ctx, nodeID, types.NodeRemoveOptions{Force: opts.force})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ func newInstallCommand(dockerCli *client.DockerCli) *cobra.Command {
|
|||
cmd := &cobra.Command{
|
||||
Use: "install [OPTIONS] PLUGIN",
|
||||
Short: "Install a plugin",
|
||||
Args: cli.RequiresMinArgs(1), // TODO: allow for set args
|
||||
Args: cli.ExactArgs(1), // TODO: allow for set args
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
options.name = args[0]
|
||||
return runInstall(dockerCli, options)
|
||||
|
|
|
@ -17,7 +17,7 @@ func newListCommand(dockerCli *client.DockerCli) *cobra.Command {
|
|||
Use: "ls",
|
||||
Short: "List plugins",
|
||||
Aliases: []string{"list"},
|
||||
Args: cli.ExactArgs(0),
|
||||
Args: cli.NoArgs,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return runList(dockerCli)
|
||||
},
|
||||
|
|
|
@ -17,7 +17,7 @@ func newRemoveCommand(dockerCli *client.DockerCli) *cobra.Command {
|
|||
Use: "rm PLUGIN",
|
||||
Short: "Remove a plugin",
|
||||
Aliases: []string{"remove"},
|
||||
Args: cli.RequiresMinArgs(1),
|
||||
Args: cli.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return runRemove(dockerCli, args)
|
||||
},
|
||||
|
|
|
@ -117,12 +117,15 @@ func printService(out io.Writer, service swarm.Service) {
|
|||
if service.Spec.TaskTemplate.Placement != nil && len(service.Spec.TaskTemplate.Placement.Constraints) > 0 {
|
||||
ioutils.FprintfIfNotEmpty(out, " Constraints\t: %s\n", strings.Join(service.Spec.TaskTemplate.Placement.Constraints, ", "))
|
||||
}
|
||||
fmt.Fprintf(out, "UpdateConfig:\n")
|
||||
fmt.Fprintf(out, " Parallelism:\t%d\n", service.Spec.UpdateConfig.Parallelism)
|
||||
if service.Spec.UpdateConfig.Delay.Nanoseconds() > 0 {
|
||||
fmt.Fprintf(out, " Delay:\t\t%s\n", service.Spec.UpdateConfig.Delay)
|
||||
if service.Spec.UpdateConfig != nil {
|
||||
fmt.Fprintf(out, "UpdateConfig:\n")
|
||||
fmt.Fprintf(out, " Parallelism:\t%d\n", service.Spec.UpdateConfig.Parallelism)
|
||||
if service.Spec.UpdateConfig.Delay.Nanoseconds() > 0 {
|
||||
fmt.Fprintf(out, " Delay:\t\t%s\n", service.Spec.UpdateConfig.Delay)
|
||||
}
|
||||
fmt.Fprintf(out, " On failure:\t%s\n", service.Spec.UpdateConfig.FailureAction)
|
||||
}
|
||||
fmt.Fprintf(out, " On failure:\t%s\n", service.Spec.UpdateConfig.FailureAction)
|
||||
|
||||
fmt.Fprintf(out, "ContainerSpec:\n")
|
||||
printContainerSpec(out, service.Spec.TaskTemplate.ContainerSpec)
|
||||
|
||||
|
@ -149,6 +152,7 @@ func printService(out io.Writer, service swarm.Service) {
|
|||
for _, n := range service.Spec.Networks {
|
||||
fmt.Fprintf(out, " %s", n.Target)
|
||||
}
|
||||
fmt.Fprintln(out, "")
|
||||
}
|
||||
|
||||
if len(service.Endpoint.Ports) > 0 {
|
||||
|
|
84
api/client/service/inspect_test.go
Normal file
84
api/client/service/inspect_test.go
Normal file
|
@ -0,0 +1,84 @@
|
|||
package service
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/docker/engine-api/types/swarm"
|
||||
)
|
||||
|
||||
func TestPrettyPrintWithNoUpdateConfig(t *testing.T) {
|
||||
b := new(bytes.Buffer)
|
||||
|
||||
endpointSpec := &swarm.EndpointSpec{
|
||||
Mode: "vip",
|
||||
Ports: []swarm.PortConfig{
|
||||
{
|
||||
Protocol: swarm.PortConfigProtocolTCP,
|
||||
TargetPort: 5000,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
two := uint64(2)
|
||||
|
||||
s := swarm.Service{
|
||||
ID: "de179gar9d0o7ltdybungplod",
|
||||
Meta: swarm.Meta{
|
||||
Version: swarm.Version{Index: 315},
|
||||
CreatedAt: time.Now(),
|
||||
UpdatedAt: time.Now(),
|
||||
},
|
||||
Spec: swarm.ServiceSpec{
|
||||
Annotations: swarm.Annotations{
|
||||
Name: "my_service",
|
||||
Labels: map[string]string{"com.label": "foo"},
|
||||
},
|
||||
TaskTemplate: swarm.TaskSpec{
|
||||
ContainerSpec: swarm.ContainerSpec{
|
||||
Image: "foo/bar@sha256:this_is_a_test",
|
||||
},
|
||||
},
|
||||
Mode: swarm.ServiceMode{
|
||||
Replicated: &swarm.ReplicatedService{
|
||||
Replicas: &two,
|
||||
},
|
||||
},
|
||||
UpdateConfig: nil,
|
||||
Networks: []swarm.NetworkAttachmentConfig{
|
||||
{
|
||||
Target: "5vpyomhb6ievnk0i0o60gcnei",
|
||||
Aliases: []string{"web"},
|
||||
},
|
||||
},
|
||||
EndpointSpec: endpointSpec,
|
||||
},
|
||||
Endpoint: swarm.Endpoint{
|
||||
Spec: *endpointSpec,
|
||||
Ports: []swarm.PortConfig{
|
||||
{
|
||||
Protocol: swarm.PortConfigProtocolTCP,
|
||||
TargetPort: 5000,
|
||||
PublishedPort: 30000,
|
||||
},
|
||||
},
|
||||
VirtualIPs: []swarm.EndpointVirtualIP{
|
||||
{
|
||||
NetworkID: "6o4107cj2jx9tihgb0jyts6pj",
|
||||
Addr: "10.255.0.4/16",
|
||||
},
|
||||
},
|
||||
},
|
||||
UpdateStatus: swarm.UpdateStatus{
|
||||
StartedAt: time.Now(),
|
||||
CompletedAt: time.Now(),
|
||||
},
|
||||
}
|
||||
|
||||
printService(b, s)
|
||||
if strings.Contains(b.String(), "UpdateStatus") {
|
||||
t.Fatal("Pretty print failed before parsing UpdateStatus")
|
||||
}
|
||||
}
|
|
@ -15,7 +15,7 @@ func newRemoveCommand(dockerCli *client.DockerCli) *cobra.Command {
|
|||
cmd := &cobra.Command{
|
||||
Use: "rm [OPTIONS] SERVICE [SERVICE...]",
|
||||
Aliases: []string{"remove"},
|
||||
Short: "Remove a service",
|
||||
Short: "Remove one or more services",
|
||||
Args: cli.RequiresMinArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return runRemove(dockerCli, args)
|
||||
|
|
|
@ -2,6 +2,7 @@ package service
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
@ -213,7 +214,9 @@ func updateService(flags *pflag.FlagSet, spec *swarm.ServiceSpec) error {
|
|||
if spec.EndpointSpec == nil {
|
||||
spec.EndpointSpec = &swarm.EndpointSpec{}
|
||||
}
|
||||
updatePorts(flags, &spec.EndpointSpec.Ports)
|
||||
if err := updatePorts(flags, &spec.EndpointSpec.Ports); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if err := updateLogDriver(flags, &spec.TaskTemplate); err != nil {
|
||||
|
@ -292,10 +295,22 @@ func updateLabels(flags *pflag.FlagSet, field *map[string]string) {
|
|||
}
|
||||
|
||||
func updateEnvironment(flags *pflag.FlagSet, field *[]string) {
|
||||
envSet := map[string]string{}
|
||||
for _, v := range *field {
|
||||
envSet[envKey(v)] = v
|
||||
}
|
||||
if flags.Changed(flagEnvAdd) {
|
||||
value := flags.Lookup(flagEnvAdd).Value.(*opts.ListOpts)
|
||||
*field = append(*field, value.GetAll()...)
|
||||
for _, v := range value.GetAll() {
|
||||
envSet[envKey(v)] = v
|
||||
}
|
||||
}
|
||||
|
||||
*field = []string{}
|
||||
for _, v := range envSet {
|
||||
*field = append(*field, v)
|
||||
}
|
||||
|
||||
toRemove := buildToRemoveSet(flags, flagEnvRemove)
|
||||
*field = removeItems(*field, toRemove, envKey)
|
||||
}
|
||||
|
@ -354,23 +369,54 @@ func updateMounts(flags *pflag.FlagSet, mounts *[]swarm.Mount) {
|
|||
*mounts = newMounts
|
||||
}
|
||||
|
||||
func updatePorts(flags *pflag.FlagSet, portConfig *[]swarm.PortConfig) {
|
||||
type byPortConfig []swarm.PortConfig
|
||||
|
||||
func (r byPortConfig) Len() int { return len(r) }
|
||||
func (r byPortConfig) Swap(i, j int) { r[i], r[j] = r[j], r[i] }
|
||||
func (r byPortConfig) Less(i, j int) bool {
|
||||
// We convert PortConfig into `port/protocol`, e.g., `80/tcp`
|
||||
// In updatePorts we already filter out with map so there is duplicate entries
|
||||
return portConfigToString(&r[i]) < portConfigToString(&r[j])
|
||||
}
|
||||
|
||||
func portConfigToString(portConfig *swarm.PortConfig) string {
|
||||
protocol := portConfig.Protocol
|
||||
if protocol == "" {
|
||||
protocol = "tcp"
|
||||
}
|
||||
return fmt.Sprintf("%v/%s", portConfig.PublishedPort, protocol)
|
||||
}
|
||||
|
||||
func updatePorts(flags *pflag.FlagSet, portConfig *[]swarm.PortConfig) error {
|
||||
// The key of the map is `port/protocol`, e.g., `80/tcp`
|
||||
portSet := map[string]swarm.PortConfig{}
|
||||
// Check to see if there are any conflict in flags.
|
||||
if flags.Changed(flagPublishAdd) {
|
||||
values := flags.Lookup(flagPublishAdd).Value.(*opts.ListOpts).GetAll()
|
||||
ports, portBindings, _ := nat.ParsePortSpecs(values)
|
||||
|
||||
for port := range ports {
|
||||
*portConfig = append(*portConfig, convertPortToPortConfig(port, portBindings)...)
|
||||
newConfigs := convertPortToPortConfig(port, portBindings)
|
||||
for _, entry := range newConfigs {
|
||||
if v, ok := portSet[portConfigToString(&entry)]; ok && v != entry {
|
||||
return fmt.Errorf("conflicting port mapping between %v:%v/%s and %v:%v/%s", entry.PublishedPort, entry.TargetPort, entry.Protocol, v.PublishedPort, v.TargetPort, v.Protocol)
|
||||
}
|
||||
portSet[portConfigToString(&entry)] = entry
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !flags.Changed(flagPublishRemove) {
|
||||
return
|
||||
// Override previous PortConfig in service if there is any duplicate
|
||||
for _, entry := range *portConfig {
|
||||
if _, ok := portSet[portConfigToString(&entry)]; !ok {
|
||||
portSet[portConfigToString(&entry)] = entry
|
||||
}
|
||||
}
|
||||
|
||||
toRemove := flags.Lookup(flagPublishRemove).Value.(*opts.ListOpts).GetAll()
|
||||
newPorts := []swarm.PortConfig{}
|
||||
portLoop:
|
||||
for _, port := range *portConfig {
|
||||
for _, port := range portSet {
|
||||
for _, rawTargetPort := range toRemove {
|
||||
targetPort := nat.Port(rawTargetPort)
|
||||
if equalPort(targetPort, port) {
|
||||
|
@ -379,7 +425,10 @@ portLoop:
|
|||
}
|
||||
newPorts = append(newPorts, port)
|
||||
}
|
||||
// Sort the PortConfig to avoid unnecessary updates
|
||||
sort.Sort(byPortConfig(newPorts))
|
||||
*portConfig = newPorts
|
||||
return nil
|
||||
}
|
||||
|
||||
func equalPort(targetPort nat.Port, port swarm.PortConfig) bool {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package service
|
||||
|
||||
import (
|
||||
"sort"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/docker/pkg/testutil/assert"
|
||||
|
@ -68,8 +69,10 @@ func TestUpdateEnvironment(t *testing.T) {
|
|||
|
||||
updateEnvironment(flags, &envs)
|
||||
assert.Equal(t, len(envs), 2)
|
||||
assert.Equal(t, envs[0], "tokeep=value")
|
||||
assert.Equal(t, envs[1], "toadd=newenv")
|
||||
// Order has been removed in updateEnvironment (map)
|
||||
sort.Strings(envs)
|
||||
assert.Equal(t, envs[0], "toadd=newenv")
|
||||
assert.Equal(t, envs[1], "tokeep=value")
|
||||
}
|
||||
|
||||
func TestUpdateEnvironmentWithDuplicateValues(t *testing.T) {
|
||||
|
@ -84,6 +87,18 @@ func TestUpdateEnvironmentWithDuplicateValues(t *testing.T) {
|
|||
assert.Equal(t, len(envs), 0)
|
||||
}
|
||||
|
||||
func TestUpdateEnvironmentWithDuplicateKeys(t *testing.T) {
|
||||
// Test case for #25404
|
||||
flags := newUpdateCommand(nil).Flags()
|
||||
flags.Set("env-add", "A=b")
|
||||
|
||||
envs := []string{"A=c"}
|
||||
|
||||
updateEnvironment(flags, &envs)
|
||||
assert.Equal(t, len(envs), 1)
|
||||
assert.Equal(t, envs[0], "A=b")
|
||||
}
|
||||
|
||||
func TestUpdateMounts(t *testing.T) {
|
||||
flags := newUpdateCommand(nil).Flags()
|
||||
flags.Set("mount-add", "type=volume,target=/toadd")
|
||||
|
@ -110,8 +125,56 @@ func TestUpdatePorts(t *testing.T) {
|
|||
{TargetPort: 555},
|
||||
}
|
||||
|
||||
updatePorts(flags, &portConfigs)
|
||||
err := updatePorts(flags, &portConfigs)
|
||||
assert.Equal(t, err, nil)
|
||||
assert.Equal(t, len(portConfigs), 2)
|
||||
assert.Equal(t, portConfigs[0].TargetPort, uint32(555))
|
||||
assert.Equal(t, portConfigs[1].TargetPort, uint32(1000))
|
||||
// Do a sort to have the order (might have changed by map)
|
||||
targetPorts := []int{int(portConfigs[0].TargetPort), int(portConfigs[1].TargetPort)}
|
||||
sort.Ints(targetPorts)
|
||||
assert.Equal(t, targetPorts[0], 555)
|
||||
assert.Equal(t, targetPorts[1], 1000)
|
||||
}
|
||||
|
||||
func TestUpdatePortsDuplicateEntries(t *testing.T) {
|
||||
// Test case for #25375
|
||||
flags := newUpdateCommand(nil).Flags()
|
||||
flags.Set("publish-add", "80:80")
|
||||
|
||||
portConfigs := []swarm.PortConfig{
|
||||
{TargetPort: 80, PublishedPort: 80},
|
||||
}
|
||||
|
||||
err := updatePorts(flags, &portConfigs)
|
||||
assert.Equal(t, err, nil)
|
||||
assert.Equal(t, len(portConfigs), 1)
|
||||
assert.Equal(t, portConfigs[0].TargetPort, uint32(80))
|
||||
}
|
||||
|
||||
func TestUpdatePortsDuplicateKeys(t *testing.T) {
|
||||
// Test case for #25375
|
||||
flags := newUpdateCommand(nil).Flags()
|
||||
flags.Set("publish-add", "80:20")
|
||||
|
||||
portConfigs := []swarm.PortConfig{
|
||||
{TargetPort: 80, PublishedPort: 80},
|
||||
}
|
||||
|
||||
err := updatePorts(flags, &portConfigs)
|
||||
assert.Equal(t, err, nil)
|
||||
assert.Equal(t, len(portConfigs), 1)
|
||||
assert.Equal(t, portConfigs[0].TargetPort, uint32(20))
|
||||
}
|
||||
|
||||
func TestUpdatePortsConflictingFlags(t *testing.T) {
|
||||
// Test case for #25375
|
||||
flags := newUpdateCommand(nil).Flags()
|
||||
flags.Set("publish-add", "80:80")
|
||||
flags.Set("publish-add", "80:20")
|
||||
|
||||
portConfigs := []swarm.PortConfig{
|
||||
{TargetPort: 80, PublishedPort: 80},
|
||||
}
|
||||
|
||||
err := updatePorts(flags, &portConfigs)
|
||||
assert.Error(t, err, "conflicting port mapping")
|
||||
}
|
||||
|
|
|
@ -72,5 +72,10 @@ func runInit(dockerCli *client.DockerCli, flags *pflag.FlagSet, opts initOptions
|
|||
|
||||
fmt.Fprintf(dockerCli.Out(), "Swarm initialized: current node (%s) is now a manager.\n\n", nodeID)
|
||||
|
||||
return printJoinCommand(ctx, dockerCli, nodeID, true, true)
|
||||
if err := printJoinCommand(ctx, dockerCli, nodeID, true, false); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Fprint(dockerCli.Out(), "To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.\n\n")
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -12,11 +12,6 @@ import (
|
|||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
const (
|
||||
flagRotate = "rotate"
|
||||
flagQuiet = "quiet"
|
||||
)
|
||||
|
||||
func newJoinTokenCommand(dockerCli *client.DockerCli) *cobra.Command {
|
||||
var rotate, quiet bool
|
||||
|
||||
|
@ -25,7 +20,10 @@ func newJoinTokenCommand(dockerCli *client.DockerCli) *cobra.Command {
|
|||
Short: "Manage join tokens",
|
||||
Args: cli.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
if args[0] != "worker" && args[0] != "manager" {
|
||||
worker := args[0] == "worker"
|
||||
manager := args[0] == "manager"
|
||||
|
||||
if !worker && !manager {
|
||||
return errors.New("unknown role " + args[0])
|
||||
}
|
||||
|
||||
|
@ -40,16 +38,16 @@ func newJoinTokenCommand(dockerCli *client.DockerCli) *cobra.Command {
|
|||
return err
|
||||
}
|
||||
|
||||
if args[0] == "worker" {
|
||||
flags.RotateWorkerToken = true
|
||||
} else if args[0] == "manager" {
|
||||
flags.RotateManagerToken = true
|
||||
}
|
||||
flags.RotateWorkerToken = worker
|
||||
flags.RotateManagerToken = manager
|
||||
|
||||
err = client.SwarmUpdate(ctx, swarm.Version, swarm.Spec, flags)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !quiet {
|
||||
fmt.Fprintf(dockerCli.Out(), "Succesfully rotated %s join token.\n\n", args[0])
|
||||
}
|
||||
}
|
||||
|
||||
swarm, err := client.SwarmInspect(ctx)
|
||||
|
@ -58,9 +56,9 @@ func newJoinTokenCommand(dockerCli *client.DockerCli) *cobra.Command {
|
|||
}
|
||||
|
||||
if quiet {
|
||||
if args[0] == "worker" {
|
||||
if worker {
|
||||
fmt.Fprintln(dockerCli.Out(), swarm.JoinTokens.Worker)
|
||||
} else if args[0] == "manager" {
|
||||
} else {
|
||||
fmt.Fprintln(dockerCli.Out(), swarm.JoinTokens.Manager)
|
||||
}
|
||||
} else {
|
||||
|
@ -68,7 +66,7 @@ func newJoinTokenCommand(dockerCli *client.DockerCli) *cobra.Command {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return printJoinCommand(ctx, dockerCli, info.Swarm.NodeID, args[0] == "worker", args[0] == "manager")
|
||||
return printJoinCommand(ctx, dockerCli, info.Swarm.NodeID, worker, manager)
|
||||
}
|
||||
return nil
|
||||
},
|
||||
|
@ -96,13 +94,10 @@ func printJoinCommand(ctx context.Context, dockerCli *client.DockerCli, nodeID s
|
|||
|
||||
if node.ManagerStatus != nil {
|
||||
if worker {
|
||||
fmt.Fprintf(dockerCli.Out(), "To add a worker to this swarm, run the following command:\n docker swarm join \\\n --token %s \\\n %s\n", swarm.JoinTokens.Worker, node.ManagerStatus.Addr)
|
||||
fmt.Fprintf(dockerCli.Out(), "To add a worker to this swarm, run the following command:\n\n docker swarm join \\\n --token %s \\\n %s\n\n", swarm.JoinTokens.Worker, node.ManagerStatus.Addr)
|
||||
}
|
||||
if manager {
|
||||
if worker {
|
||||
fmt.Fprintln(dockerCli.Out())
|
||||
}
|
||||
fmt.Fprintf(dockerCli.Out(), "To add a manager to this swarm, run the following command:\n docker swarm join \\\n --token %s \\\n %s\n", swarm.JoinTokens.Manager, node.ManagerStatus.Addr)
|
||||
fmt.Fprintf(dockerCli.Out(), "To add a manager to this swarm, run the following command:\n\n docker swarm join \\\n --token %s \\\n %s\n\n", swarm.JoinTokens.Manager, node.ManagerStatus.Addr)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,8 @@ const (
|
|||
flagDispatcherHeartbeat = "dispatcher-heartbeat"
|
||||
flagListenAddr = "listen-addr"
|
||||
flagAdvertiseAddr = "advertise-addr"
|
||||
flagQuiet = "quiet"
|
||||
flagRotate = "rotate"
|
||||
flagToken = "token"
|
||||
flagTaskHistoryLimit = "task-history-limit"
|
||||
flagExternalCA = "external-ca"
|
||||
|
|
|
@ -44,7 +44,7 @@ func NewVersionCommand(dockerCli *client.DockerCli) *cobra.Command {
|
|||
cmd := &cobra.Command{
|
||||
Use: "version [OPTIONS]",
|
||||
Short: "Show the Docker version information",
|
||||
Args: cli.ExactArgs(0),
|
||||
Args: cli.NoArgs,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return runVersion(dockerCli, &opts)
|
||||
},
|
||||
|
|
|
@ -12,9 +12,9 @@ import (
|
|||
|
||||
func newRemoveCommand(dockerCli *client.DockerCli) *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "rm VOLUME [VOLUME]...",
|
||||
Use: "rm VOLUME [VOLUME...]",
|
||||
Aliases: []string{"remove"},
|
||||
Short: "Remove a volume",
|
||||
Short: "Remove one or more volumes",
|
||||
Long: removeDescription,
|
||||
Example: removeExample,
|
||||
Args: cli.RequiresMinArgs(1),
|
||||
|
@ -45,7 +45,7 @@ func runRemove(dockerCli *client.DockerCli, volumes []string) error {
|
|||
}
|
||||
|
||||
var removeDescription = `
|
||||
Removes one or more volumes. You cannot remove a volume that is in use by a container.
|
||||
Remove one or more volumes. You cannot remove a volume that is in use by a container.
|
||||
`
|
||||
|
||||
var removeExample = `
|
||||
|
|
|
@ -64,7 +64,7 @@ func maskSecretKeys(inp interface{}) {
|
|||
if form, ok := inp.(map[string]interface{}); ok {
|
||||
loop0:
|
||||
for k, v := range form {
|
||||
for _, m := range []string{"password", "secret"} {
|
||||
for _, m := range []string{"password", "secret", "jointoken"} {
|
||||
if strings.EqualFold(m, k) {
|
||||
form[k] = "*****"
|
||||
continue loop0
|
||||
|
|
|
@ -20,7 +20,7 @@ type Backend interface {
|
|||
GetNodes(basictypes.NodeListOptions) ([]types.Node, error)
|
||||
GetNode(string) (types.Node, error)
|
||||
UpdateNode(string, uint64, types.NodeSpec) error
|
||||
RemoveNode(string) error
|
||||
RemoveNode(string, bool) error
|
||||
GetTasks(basictypes.TaskListOptions) ([]types.Task, error)
|
||||
GetTask(string) (types.Task, error)
|
||||
}
|
||||
|
|
|
@ -219,7 +219,13 @@ func (sr *swarmRouter) updateNode(ctx context.Context, w http.ResponseWriter, r
|
|||
}
|
||||
|
||||
func (sr *swarmRouter) removeNode(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
||||
if err := sr.backend.RemoveNode(vars["id"]); err != nil {
|
||||
if err := httputils.ParseForm(r); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
force := httputils.BoolValue(r, "force")
|
||||
|
||||
if err := sr.backend.RemoveNode(vars["id"], force); err != nil {
|
||||
logrus.Errorf("Error removing node %s: %v", vars["id"], err)
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -262,10 +262,6 @@ func (cli *DaemonCli) start() (err error) {
|
|||
<-stopc // wait for daemonCli.start() to return
|
||||
})
|
||||
|
||||
if err := pluginInit(cli.Config, containerdRemote, registryService); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
d, err := daemon.NewDaemon(cli.Config, registryService, containerdRemote)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error starting daemon: %v", err)
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
// +build !experimental !linux
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/docker/docker/daemon"
|
||||
"github.com/docker/docker/libcontainerd"
|
||||
"github.com/docker/docker/registry"
|
||||
)
|
||||
|
||||
func pluginInit(config *daemon.Config, remote libcontainerd.Remote, rs registry.Service) error {
|
||||
return nil
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
// +build linux,experimental
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/docker/docker/daemon"
|
||||
"github.com/docker/docker/libcontainerd"
|
||||
"github.com/docker/docker/plugin"
|
||||
"github.com/docker/docker/registry"
|
||||
)
|
||||
|
||||
func pluginInit(config *daemon.Config, remote libcontainerd.Remote, rs registry.Service) error {
|
||||
return plugin.Init(config.Root, remote, rs, config.LiveRestore)
|
||||
}
|
|
@ -325,7 +325,7 @@ func (container *Container) UnmountVolumes(forceSyscall bool, volumeEventLog fun
|
|||
return err
|
||||
}
|
||||
|
||||
volumeMounts = append(volumeMounts, volume.MountPoint{Destination: dest, Volume: mntPoint.Volume})
|
||||
volumeMounts = append(volumeMounts, volume.MountPoint{Destination: dest, Volume: mntPoint.Volume, ID: mntPoint.ID})
|
||||
}
|
||||
|
||||
// Append any network mounts to the list (this is a no-op on Windows)
|
||||
|
|
|
@ -1774,7 +1774,8 @@ _docker_service_update() {
|
|||
return
|
||||
;;
|
||||
--env|-e)
|
||||
COMPREPLY=( $( compgen -e -S = -- "$cur" ) )
|
||||
# we do not append a "=" here because "-e VARNAME" is legal systax, too
|
||||
COMPREPLY=( $( compgen -e -- "$cur" ) )
|
||||
__docker_nospace
|
||||
return
|
||||
;;
|
||||
|
@ -1878,7 +1879,7 @@ _docker_swarm_join() {
|
|||
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "--adveritse-addr --help --listen-addr --token" -- "$cur" ) )
|
||||
COMPREPLY=( $( compgen -W "--advertise-addr --help --listen-addr --token" -- "$cur" ) )
|
||||
;;
|
||||
*:)
|
||||
COMPREPLY=( $( compgen -W "2377" -- "${cur##*:}" ) )
|
||||
|
@ -2019,7 +2020,7 @@ _docker_node_remove() {
|
|||
_docker_node_rm() {
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
|
||||
COMPREPLY=( $( compgen -W "--force --help" -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
__docker_complete_nodes
|
||||
|
@ -2431,6 +2432,7 @@ _docker_run() {
|
|||
return
|
||||
;;
|
||||
--env|-e)
|
||||
# we do not append a "=" here because "-e VARNAME" is legal systax, too
|
||||
COMPREPLY=( $( compgen -e -- "$cur" ) )
|
||||
__docker_nospace
|
||||
return
|
||||
|
|
|
@ -787,7 +787,7 @@ __docker_node_commands() {
|
|||
"inspect:Display detailed information on one or more nodes"
|
||||
"ls:List nodes in the swarm"
|
||||
"promote:Promote a node as manager in the swarm"
|
||||
"rm:Remove a node from the swarm"
|
||||
"rm:Remove one or more nodes from the swarm"
|
||||
"ps:List tasks running on a node"
|
||||
"update:Update a node"
|
||||
)
|
||||
|
@ -805,6 +805,7 @@ __docker_node_subcommand() {
|
|||
(rm|remove)
|
||||
_arguments $(__docker_arguments) \
|
||||
$opts_help \
|
||||
"($help)--force[Force remove an active node]" \
|
||||
"($help -)*:node:__docker_complete_pending_nodes" && ret=0
|
||||
;;
|
||||
(demote)
|
||||
|
@ -1059,7 +1060,7 @@ __docker_service_commands() {
|
|||
"create:Create a new service"
|
||||
"inspect:Display detailed information on one or more services"
|
||||
"ls:List services"
|
||||
"rm:Remove a service"
|
||||
"rm:Remove one or more services"
|
||||
"scale:Scale one or multiple services"
|
||||
"ps:List the tasks of a service"
|
||||
"update:Update a service"
|
||||
|
@ -1107,6 +1108,7 @@ __docker_service_subcommand() {
|
|||
_arguments $(__docker_arguments) \
|
||||
$opts_help \
|
||||
$opts_create_update \
|
||||
"($help)*--container-label=[Container labels]:label: " \
|
||||
"($help)--mode=[Service Mode]:mode:(global replicated)" \
|
||||
"($help -): :__docker_images" \
|
||||
"($help -):command: _command_names -e" \
|
||||
|
@ -1167,6 +1169,8 @@ __docker_service_subcommand() {
|
|||
$opts_help \
|
||||
$opts_create_update \
|
||||
"($help)--arg=[Service command args]:arguments: _normal" \
|
||||
"($help)*--container-label-add=[Add or update container labels]:label: " \
|
||||
"($help)*--container-label-rm=[Remove a container label by its key]:label: " \
|
||||
"($help)--image=[Service image tag]:image:__docker_repositories" \
|
||||
"($help -)1:service:__docker_complete_services" && ret=0
|
||||
;;
|
||||
|
@ -1186,7 +1190,6 @@ __docker_swarm_commands() {
|
|||
local -a _docker_swarm_subcommands
|
||||
_docker_swarm_subcommands=(
|
||||
"init:Initialize a swarm"
|
||||
"inspect:Inspect the swarm"
|
||||
"join:Join a swarm as a node and/or manager"
|
||||
"join-token:Manage join tokens"
|
||||
"leave:Leave a swarm"
|
||||
|
@ -1211,11 +1214,6 @@ __docker_swarm_subcommand() {
|
|||
"($help)--force-new-cluster[Force create a new cluster from current state]" \
|
||||
"($help)--listen-addr=[Listen address]:ip\:port: " && ret=0
|
||||
;;
|
||||
(inspect)
|
||||
_arguments $(__docker_arguments) \
|
||||
$opts_help \
|
||||
"($help -f --format)"{-f=,--format=}"[Format the output using the given go template]:template: " && ret=0
|
||||
;;
|
||||
(join)
|
||||
_arguments $(__docker_arguments) \
|
||||
$opts_help \
|
||||
|
@ -1318,7 +1316,7 @@ __docker_volume_commands() {
|
|||
"create:Create a volume"
|
||||
"inspect:Display detailed information on one or more volumes"
|
||||
"ls:List volumes"
|
||||
"rm:Remove a volume"
|
||||
"rm:Remove one or more volumes"
|
||||
)
|
||||
_describe -t docker-volume-commands "docker volume command" _docker_volume_subcommands
|
||||
}
|
||||
|
|
339
contrib/selinux-fedora-24/docker-engine-selinux/LICENSE
Normal file
339
contrib/selinux-fedora-24/docker-engine-selinux/LICENSE
Normal file
|
@ -0,0 +1,339 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
23
contrib/selinux-fedora-24/docker-engine-selinux/Makefile
Normal file
23
contrib/selinux-fedora-24/docker-engine-selinux/Makefile
Normal file
|
@ -0,0 +1,23 @@
|
|||
TARGETS?=docker
|
||||
MODULES?=${TARGETS:=.pp.bz2}
|
||||
SHAREDIR?=/usr/share
|
||||
|
||||
all: ${TARGETS:=.pp.bz2}
|
||||
|
||||
%.pp.bz2: %.pp
|
||||
@echo Compressing $^ -\> $@
|
||||
bzip2 -9 $^
|
||||
|
||||
%.pp: %.te
|
||||
make -f ${SHAREDIR}/selinux/devel/Makefile $@
|
||||
|
||||
clean:
|
||||
rm -f *~ *.tc *.pp *.pp.bz2
|
||||
rm -rf tmp *.tar.gz
|
||||
|
||||
man: install
|
||||
sepolicy manpage --domain ${TARGETS}_t
|
||||
|
||||
install:
|
||||
semodule -i ${TARGETS}
|
||||
|
|
@ -0,0 +1 @@
|
|||
SELinux policy for docker
|
29
contrib/selinux-fedora-24/docker-engine-selinux/docker.fc
Normal file
29
contrib/selinux-fedora-24/docker-engine-selinux/docker.fc
Normal file
|
@ -0,0 +1,29 @@
|
|||
/root/\.docker gen_context(system_u:object_r:docker_home_t,s0)
|
||||
|
||||
/usr/bin/docker -- gen_context(system_u:object_r:docker_exec_t,s0)
|
||||
/usr/bin/docker-novolume-plugin -- gen_context(system_u:object_r:docker_auth_exec_t,s0)
|
||||
/usr/lib/docker/docker-novolume-plugin -- gen_context(system_u:object_r:docker_auth_exec_t,s0)
|
||||
|
||||
/usr/lib/systemd/system/docker.service -- gen_context(system_u:object_r:docker_unit_file_t,s0)
|
||||
/usr/lib/systemd/system/docker-novolume-plugin.service -- gen_context(system_u:object_r:docker_unit_file_t,s0)
|
||||
|
||||
/etc/docker(/.*)? gen_context(system_u:object_r:docker_config_t,s0)
|
||||
|
||||
/var/lib/docker(/.*)? gen_context(system_u:object_r:docker_var_lib_t,s0)
|
||||
/var/lib/kublet(/.*)? gen_context(system_u:object_r:docker_var_lib_t,s0)
|
||||
/var/lib/docker/vfs(/.*)? gen_context(system_u:object_r:svirt_sandbox_file_t,s0)
|
||||
|
||||
/var/run/docker(/.*)? gen_context(system_u:object_r:docker_var_run_t,s0)
|
||||
/var/run/docker\.pid -- gen_context(system_u:object_r:docker_var_run_t,s0)
|
||||
/var/run/docker\.sock -s gen_context(system_u:object_r:docker_var_run_t,s0)
|
||||
/var/run/docker-client(/.*)? gen_context(system_u:object_r:docker_var_run_t,s0)
|
||||
/var/run/docker/plugins(/.*)? gen_context(system_u:object_r:docker_plugin_var_run_t,s0)
|
||||
|
||||
/var/lock/lxc(/.*)? gen_context(system_u:object_r:docker_lock_t,s0)
|
||||
|
||||
/var/log/lxc(/.*)? gen_context(system_u:object_r:docker_log_t,s0)
|
||||
|
||||
/var/lib/docker/init(/.*)? gen_context(system_u:object_r:docker_share_t,s0)
|
||||
/var/lib/docker/containers/.*/hosts gen_context(system_u:object_r:docker_share_t,s0)
|
||||
/var/lib/docker/containers/.*/hostname gen_context(system_u:object_r:docker_share_t,s0)
|
||||
/var/lib/docker/.*/config\.env gen_context(system_u:object_r:docker_share_t,s0)
|
523
contrib/selinux-fedora-24/docker-engine-selinux/docker.if
Normal file
523
contrib/selinux-fedora-24/docker-engine-selinux/docker.if
Normal file
|
@ -0,0 +1,523 @@
|
|||
|
||||
## <summary>The open-source application container engine.</summary>
|
||||
|
||||
########################################
|
||||
## <summary>
|
||||
## Execute docker in the docker domain.
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed to transition.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`docker_domtrans',`
|
||||
gen_require(`
|
||||
type docker_t, docker_exec_t;
|
||||
')
|
||||
|
||||
corecmd_search_bin($1)
|
||||
domtrans_pattern($1, docker_exec_t, docker_t)
|
||||
')
|
||||
|
||||
########################################
|
||||
## <summary>
|
||||
## Execute docker in the caller domain.
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed to transition.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`docker_exec',`
|
||||
gen_require(`
|
||||
type docker_exec_t;
|
||||
')
|
||||
|
||||
corecmd_search_bin($1)
|
||||
can_exec($1, docker_exec_t)
|
||||
')
|
||||
|
||||
########################################
|
||||
## <summary>
|
||||
## Search docker lib directories.
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed access.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`docker_search_lib',`
|
||||
gen_require(`
|
||||
type docker_var_lib_t;
|
||||
')
|
||||
|
||||
allow $1 docker_var_lib_t:dir search_dir_perms;
|
||||
files_search_var_lib($1)
|
||||
')
|
||||
|
||||
########################################
|
||||
## <summary>
|
||||
## Execute docker lib directories.
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed access.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`docker_exec_lib',`
|
||||
gen_require(`
|
||||
type docker_var_lib_t;
|
||||
')
|
||||
|
||||
allow $1 docker_var_lib_t:dir search_dir_perms;
|
||||
can_exec($1, docker_var_lib_t)
|
||||
')
|
||||
|
||||
########################################
|
||||
## <summary>
|
||||
## Read docker lib files.
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed access.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`docker_read_lib_files',`
|
||||
gen_require(`
|
||||
type docker_var_lib_t;
|
||||
')
|
||||
|
||||
files_search_var_lib($1)
|
||||
read_files_pattern($1, docker_var_lib_t, docker_var_lib_t)
|
||||
')
|
||||
|
||||
########################################
|
||||
## <summary>
|
||||
## Read docker share files.
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed access.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`docker_read_share_files',`
|
||||
gen_require(`
|
||||
type docker_share_t;
|
||||
')
|
||||
|
||||
files_search_var_lib($1)
|
||||
list_dirs_pattern($1, docker_share_t, docker_share_t)
|
||||
read_files_pattern($1, docker_share_t, docker_share_t)
|
||||
read_lnk_files_pattern($1, docker_share_t, docker_share_t)
|
||||
')
|
||||
|
||||
######################################
|
||||
## <summary>
|
||||
## Allow the specified domain to execute apache
|
||||
## in the caller domain.
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed access.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`apache_exec',`
|
||||
gen_require(`
|
||||
type httpd_exec_t;
|
||||
')
|
||||
|
||||
can_exec($1, httpd_exec_t)
|
||||
')
|
||||
|
||||
######################################
|
||||
## <summary>
|
||||
## Allow the specified domain to execute docker shared files
|
||||
## in the caller domain.
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed access.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`docker_exec_share_files',`
|
||||
gen_require(`
|
||||
type docker_share_t;
|
||||
')
|
||||
|
||||
can_exec($1, docker_share_t)
|
||||
')
|
||||
|
||||
########################################
|
||||
## <summary>
|
||||
## Manage docker lib files.
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed access.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`docker_manage_lib_files',`
|
||||
gen_require(`
|
||||
type docker_var_lib_t;
|
||||
')
|
||||
|
||||
files_search_var_lib($1)
|
||||
manage_files_pattern($1, docker_var_lib_t, docker_var_lib_t)
|
||||
manage_lnk_files_pattern($1, docker_var_lib_t, docker_var_lib_t)
|
||||
')
|
||||
|
||||
########################################
|
||||
## <summary>
|
||||
## Manage docker lib directories.
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed access.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`docker_manage_lib_dirs',`
|
||||
gen_require(`
|
||||
type docker_var_lib_t;
|
||||
')
|
||||
|
||||
files_search_var_lib($1)
|
||||
manage_dirs_pattern($1, docker_var_lib_t, docker_var_lib_t)
|
||||
')
|
||||
|
||||
########################################
|
||||
## <summary>
|
||||
## Create objects in a docker var lib directory
|
||||
## with an automatic type transition to
|
||||
## a specified private type.
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed access.
|
||||
## </summary>
|
||||
## </param>
|
||||
## <param name="private_type">
|
||||
## <summary>
|
||||
## The type of the object to create.
|
||||
## </summary>
|
||||
## </param>
|
||||
## <param name="object_class">
|
||||
## <summary>
|
||||
## The class of the object to be created.
|
||||
## </summary>
|
||||
## </param>
|
||||
## <param name="name" optional="true">
|
||||
## <summary>
|
||||
## The name of the object being created.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`docker_lib_filetrans',`
|
||||
gen_require(`
|
||||
type docker_var_lib_t;
|
||||
')
|
||||
|
||||
filetrans_pattern($1, docker_var_lib_t, $2, $3, $4)
|
||||
')
|
||||
|
||||
########################################
|
||||
## <summary>
|
||||
## Read docker PID files.
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed access.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`docker_read_pid_files',`
|
||||
gen_require(`
|
||||
type docker_var_run_t;
|
||||
')
|
||||
|
||||
files_search_pids($1)
|
||||
read_files_pattern($1, docker_var_run_t, docker_var_run_t)
|
||||
')
|
||||
|
||||
########################################
|
||||
## <summary>
|
||||
## Execute docker server in the docker domain.
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed to transition.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`docker_systemctl',`
|
||||
gen_require(`
|
||||
type docker_t;
|
||||
type docker_unit_file_t;
|
||||
')
|
||||
|
||||
systemd_exec_systemctl($1)
|
||||
init_reload_services($1)
|
||||
systemd_read_fifo_file_passwd_run($1)
|
||||
allow $1 docker_unit_file_t:file read_file_perms;
|
||||
allow $1 docker_unit_file_t:service manage_service_perms;
|
||||
|
||||
ps_process_pattern($1, docker_t)
|
||||
')
|
||||
|
||||
########################################
|
||||
## <summary>
|
||||
## Read and write docker shared memory.
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed access.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`docker_rw_sem',`
|
||||
gen_require(`
|
||||
type docker_t;
|
||||
')
|
||||
|
||||
allow $1 docker_t:sem rw_sem_perms;
|
||||
')
|
||||
|
||||
#######################################
|
||||
## <summary>
|
||||
## Read and write the docker pty type.
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed access.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`docker_use_ptys',`
|
||||
gen_require(`
|
||||
type docker_devpts_t;
|
||||
')
|
||||
|
||||
allow $1 docker_devpts_t:chr_file rw_term_perms;
|
||||
')
|
||||
|
||||
#######################################
|
||||
## <summary>
|
||||
## Allow domain to create docker content
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed access.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`docker_filetrans_named_content',`
|
||||
|
||||
gen_require(`
|
||||
type docker_var_lib_t;
|
||||
type docker_share_t;
|
||||
type docker_log_t;
|
||||
type docker_var_run_t;
|
||||
type docker_home_t;
|
||||
')
|
||||
|
||||
files_pid_filetrans($1, docker_var_run_t, file, "docker.pid")
|
||||
files_pid_filetrans($1, docker_var_run_t, sock_file, "docker.sock")
|
||||
files_pid_filetrans($1, docker_var_run_t, dir, "docker-client")
|
||||
logging_log_filetrans($1, docker_log_t, dir, "lxc")
|
||||
files_var_lib_filetrans($1, docker_var_lib_t, dir, "docker")
|
||||
filetrans_pattern($1, docker_var_lib_t, docker_share_t, file, "config.env")
|
||||
filetrans_pattern($1, docker_var_lib_t, docker_share_t, file, "hosts")
|
||||
filetrans_pattern($1, docker_var_lib_t, docker_share_t, file, "hostname")
|
||||
filetrans_pattern($1, docker_var_lib_t, docker_share_t, file, "resolv.conf")
|
||||
filetrans_pattern($1, docker_var_lib_t, docker_share_t, dir, "init")
|
||||
userdom_admin_home_dir_filetrans($1, docker_home_t, dir, ".docker")
|
||||
')
|
||||
|
||||
########################################
|
||||
## <summary>
|
||||
## Connect to docker over a unix stream socket.
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed access.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`docker_stream_connect',`
|
||||
gen_require(`
|
||||
type docker_t, docker_var_run_t;
|
||||
')
|
||||
|
||||
files_search_pids($1)
|
||||
stream_connect_pattern($1, docker_var_run_t, docker_var_run_t, docker_t)
|
||||
')
|
||||
|
||||
########################################
|
||||
## <summary>
|
||||
## Connect to SPC containers over a unix stream socket.
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed access.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`docker_spc_stream_connect',`
|
||||
gen_require(`
|
||||
type spc_t, spc_var_run_t;
|
||||
')
|
||||
|
||||
files_search_pids($1)
|
||||
files_write_all_pid_sockets($1)
|
||||
allow $1 spc_t:unix_stream_socket connectto;
|
||||
')
|
||||
|
||||
########################################
|
||||
## <summary>
|
||||
## All of the rules required to administrate
|
||||
## an docker environment
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed access.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`docker_admin',`
|
||||
gen_require(`
|
||||
type docker_t;
|
||||
type docker_var_lib_t, docker_var_run_t;
|
||||
type docker_unit_file_t;
|
||||
type docker_lock_t;
|
||||
type docker_log_t;
|
||||
type docker_config_t;
|
||||
')
|
||||
|
||||
allow $1 docker_t:process { ptrace signal_perms };
|
||||
ps_process_pattern($1, docker_t)
|
||||
|
||||
admin_pattern($1, docker_config_t)
|
||||
|
||||
files_search_var_lib($1)
|
||||
admin_pattern($1, docker_var_lib_t)
|
||||
|
||||
files_search_pids($1)
|
||||
admin_pattern($1, docker_var_run_t)
|
||||
|
||||
files_search_locks($1)
|
||||
admin_pattern($1, docker_lock_t)
|
||||
|
||||
logging_search_logs($1)
|
||||
admin_pattern($1, docker_log_t)
|
||||
|
||||
docker_systemctl($1)
|
||||
admin_pattern($1, docker_unit_file_t)
|
||||
allow $1 docker_unit_file_t:service all_service_perms;
|
||||
|
||||
optional_policy(`
|
||||
systemd_passwd_agent_exec($1)
|
||||
systemd_read_fifo_file_passwd_run($1)
|
||||
')
|
||||
')
|
||||
|
||||
########################################
|
||||
## <summary>
|
||||
## Execute docker_auth_exec_t in the docker_auth domain.
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed to transition.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`docker_auth_domtrans',`
|
||||
gen_require(`
|
||||
type docker_auth_t, docker_auth_exec_t;
|
||||
')
|
||||
|
||||
corecmd_search_bin($1)
|
||||
domtrans_pattern($1, docker_auth_exec_t, docker_auth_t)
|
||||
')
|
||||
|
||||
######################################
|
||||
## <summary>
|
||||
## Execute docker_auth in the caller domain.
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed access.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`docker_auth_exec',`
|
||||
gen_require(`
|
||||
type docker_auth_exec_t;
|
||||
')
|
||||
|
||||
corecmd_search_bin($1)
|
||||
can_exec($1, docker_auth_exec_t)
|
||||
')
|
||||
|
||||
########################################
|
||||
## <summary>
|
||||
## Connect to docker_auth over a unix stream socket.
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed access.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`docker_auth_stream_connect',`
|
||||
gen_require(`
|
||||
type docker_auth_t, docker_plugin_var_run_t;
|
||||
')
|
||||
|
||||
files_search_pids($1)
|
||||
stream_connect_pattern($1, docker_plugin_var_run_t, docker_plugin_var_run_t, docker_auth_t)
|
||||
')
|
||||
|
||||
########################################
|
||||
## <summary>
|
||||
## docker domain typebounds calling domain.
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain to be typebound.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`docker_typebounds',`
|
||||
gen_require(`
|
||||
type docker_t;
|
||||
')
|
||||
|
||||
typebounds docker_t $1;
|
||||
')
|
||||
|
||||
########################################
|
||||
## <summary>
|
||||
## Allow any docker_exec_t to be an entrypoint of this domain
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed access.
|
||||
## </summary>
|
||||
## </param>
|
||||
## <rolecap/>
|
||||
#
|
||||
interface(`docker_entrypoint',`
|
||||
gen_require(`
|
||||
type docker_exec_t;
|
||||
')
|
||||
allow $1 docker_exec_t:file entrypoint;
|
||||
')
|
399
contrib/selinux-fedora-24/docker-engine-selinux/docker.te
Normal file
399
contrib/selinux-fedora-24/docker-engine-selinux/docker.te
Normal file
|
@ -0,0 +1,399 @@
|
|||
policy_module(docker, 1.0.0)
|
||||
|
||||
########################################
|
||||
#
|
||||
# Declarations
|
||||
#
|
||||
|
||||
## <desc>
|
||||
## <p>
|
||||
## Determine whether docker can
|
||||
## connect to all TCP ports.
|
||||
## </p>
|
||||
## </desc>
|
||||
gen_tunable(docker_connect_any, false)
|
||||
|
||||
type docker_t;
|
||||
type docker_exec_t;
|
||||
init_daemon_domain(docker_t, docker_exec_t)
|
||||
domain_subj_id_change_exemption(docker_t)
|
||||
domain_role_change_exemption(docker_t)
|
||||
|
||||
type spc_t;
|
||||
domain_type(spc_t)
|
||||
role system_r types spc_t;
|
||||
|
||||
type docker_auth_t;
|
||||
type docker_auth_exec_t;
|
||||
init_daemon_domain(docker_auth_t, docker_auth_exec_t)
|
||||
|
||||
type spc_var_run_t;
|
||||
files_pid_file(spc_var_run_t)
|
||||
|
||||
type docker_var_lib_t;
|
||||
files_type(docker_var_lib_t)
|
||||
|
||||
type docker_home_t;
|
||||
userdom_user_home_content(docker_home_t)
|
||||
|
||||
type docker_config_t;
|
||||
files_config_file(docker_config_t)
|
||||
|
||||
type docker_lock_t;
|
||||
files_lock_file(docker_lock_t)
|
||||
|
||||
type docker_log_t;
|
||||
logging_log_file(docker_log_t)
|
||||
|
||||
type docker_tmp_t;
|
||||
files_tmp_file(docker_tmp_t)
|
||||
|
||||
type docker_tmpfs_t;
|
||||
files_tmpfs_file(docker_tmpfs_t)
|
||||
|
||||
type docker_var_run_t;
|
||||
files_pid_file(docker_var_run_t)
|
||||
|
||||
type docker_plugin_var_run_t;
|
||||
files_pid_file(docker_plugin_var_run_t)
|
||||
|
||||
type docker_unit_file_t;
|
||||
systemd_unit_file(docker_unit_file_t)
|
||||
|
||||
type docker_devpts_t;
|
||||
term_pty(docker_devpts_t)
|
||||
|
||||
type docker_share_t;
|
||||
files_type(docker_share_t)
|
||||
|
||||
########################################
|
||||
#
|
||||
# docker local policy
|
||||
#
|
||||
allow docker_t self:capability { chown kill fowner fsetid mknod net_admin net_bind_service net_raw setfcap };
|
||||
allow docker_t self:tun_socket relabelto;
|
||||
allow docker_t self:process { getattr signal_perms setrlimit setfscreate };
|
||||
allow docker_t self:fifo_file rw_fifo_file_perms;
|
||||
allow docker_t self:unix_stream_socket create_stream_socket_perms;
|
||||
allow docker_t self:tcp_socket create_stream_socket_perms;
|
||||
allow docker_t self:udp_socket create_socket_perms;
|
||||
allow docker_t self:capability2 block_suspend;
|
||||
|
||||
docker_auth_stream_connect(docker_t)
|
||||
|
||||
manage_files_pattern(docker_t, docker_home_t, docker_home_t)
|
||||
manage_dirs_pattern(docker_t, docker_home_t, docker_home_t)
|
||||
manage_lnk_files_pattern(docker_t, docker_home_t, docker_home_t)
|
||||
userdom_admin_home_dir_filetrans(docker_t, docker_home_t, dir, ".docker")
|
||||
|
||||
manage_dirs_pattern(docker_t, docker_config_t, docker_config_t)
|
||||
manage_files_pattern(docker_t, docker_config_t, docker_config_t)
|
||||
files_etc_filetrans(docker_t, docker_config_t, dir, "docker")
|
||||
|
||||
manage_dirs_pattern(docker_t, docker_lock_t, docker_lock_t)
|
||||
manage_files_pattern(docker_t, docker_lock_t, docker_lock_t)
|
||||
files_lock_filetrans(docker_t, docker_lock_t, { dir file }, "lxc")
|
||||
|
||||
manage_dirs_pattern(docker_t, docker_log_t, docker_log_t)
|
||||
manage_files_pattern(docker_t, docker_log_t, docker_log_t)
|
||||
manage_lnk_files_pattern(docker_t, docker_log_t, docker_log_t)
|
||||
logging_log_filetrans(docker_t, docker_log_t, { dir file lnk_file })
|
||||
allow docker_t docker_log_t:dir_file_class_set { relabelfrom relabelto };
|
||||
|
||||
manage_dirs_pattern(docker_t, docker_tmp_t, docker_tmp_t)
|
||||
manage_files_pattern(docker_t, docker_tmp_t, docker_tmp_t)
|
||||
manage_lnk_files_pattern(docker_t, docker_tmp_t, docker_tmp_t)
|
||||
files_tmp_filetrans(docker_t, docker_tmp_t, { dir file lnk_file })
|
||||
|
||||
manage_dirs_pattern(docker_t, docker_tmpfs_t, docker_tmpfs_t)
|
||||
manage_files_pattern(docker_t, docker_tmpfs_t, docker_tmpfs_t)
|
||||
manage_lnk_files_pattern(docker_t, docker_tmpfs_t, docker_tmpfs_t)
|
||||
manage_fifo_files_pattern(docker_t, docker_tmpfs_t, docker_tmpfs_t)
|
||||
manage_chr_files_pattern(docker_t, docker_tmpfs_t, docker_tmpfs_t)
|
||||
manage_blk_files_pattern(docker_t, docker_tmpfs_t, docker_tmpfs_t)
|
||||
allow docker_t docker_tmpfs_t:dir relabelfrom;
|
||||
can_exec(docker_t, docker_tmpfs_t)
|
||||
fs_tmpfs_filetrans(docker_t, docker_tmpfs_t, { dir file })
|
||||
allow docker_t docker_tmpfs_t:chr_file mounton;
|
||||
|
||||
manage_dirs_pattern(docker_t, docker_share_t, docker_share_t)
|
||||
manage_files_pattern(docker_t, docker_share_t, docker_share_t)
|
||||
manage_lnk_files_pattern(docker_t, docker_share_t, docker_share_t)
|
||||
allow docker_t docker_share_t:dir_file_class_set { relabelfrom relabelto };
|
||||
|
||||
can_exec(docker_t, docker_share_t)
|
||||
#docker_filetrans_named_content(docker_t)
|
||||
|
||||
manage_dirs_pattern(docker_t, docker_var_lib_t, docker_var_lib_t)
|
||||
manage_chr_files_pattern(docker_t, docker_var_lib_t, docker_var_lib_t)
|
||||
manage_blk_files_pattern(docker_t, docker_var_lib_t, docker_var_lib_t)
|
||||
manage_files_pattern(docker_t, docker_var_lib_t, docker_var_lib_t)
|
||||
manage_lnk_files_pattern(docker_t, docker_var_lib_t, docker_var_lib_t)
|
||||
allow docker_t docker_var_lib_t:dir_file_class_set { relabelfrom relabelto };
|
||||
files_var_lib_filetrans(docker_t, docker_var_lib_t, { dir file lnk_file })
|
||||
|
||||
manage_dirs_pattern(docker_t, docker_var_run_t, docker_var_run_t)
|
||||
manage_files_pattern(docker_t, docker_var_run_t, docker_var_run_t)
|
||||
manage_sock_files_pattern(docker_t, docker_var_run_t, docker_var_run_t)
|
||||
manage_lnk_files_pattern(docker_t, docker_var_run_t, docker_var_run_t)
|
||||
files_pid_filetrans(docker_t, docker_var_run_t, { dir file lnk_file sock_file })
|
||||
|
||||
allow docker_t docker_devpts_t:chr_file { relabelfrom rw_chr_file_perms setattr_chr_file_perms };
|
||||
term_create_pty(docker_t, docker_devpts_t)
|
||||
|
||||
kernel_read_system_state(docker_t)
|
||||
kernel_read_network_state(docker_t)
|
||||
kernel_read_all_sysctls(docker_t)
|
||||
kernel_rw_net_sysctls(docker_t)
|
||||
kernel_setsched(docker_t)
|
||||
kernel_read_all_proc(docker_t)
|
||||
|
||||
domain_use_interactive_fds(docker_t)
|
||||
domain_dontaudit_read_all_domains_state(docker_t)
|
||||
|
||||
corecmd_exec_bin(docker_t)
|
||||
corecmd_exec_shell(docker_t)
|
||||
|
||||
corenet_tcp_bind_generic_node(docker_t)
|
||||
corenet_tcp_sendrecv_generic_if(docker_t)
|
||||
corenet_tcp_sendrecv_generic_node(docker_t)
|
||||
corenet_tcp_sendrecv_generic_port(docker_t)
|
||||
corenet_tcp_bind_all_ports(docker_t)
|
||||
corenet_tcp_connect_http_port(docker_t)
|
||||
corenet_tcp_connect_commplex_main_port(docker_t)
|
||||
corenet_udp_sendrecv_generic_if(docker_t)
|
||||
corenet_udp_sendrecv_generic_node(docker_t)
|
||||
corenet_udp_sendrecv_all_ports(docker_t)
|
||||
corenet_udp_bind_generic_node(docker_t)
|
||||
corenet_udp_bind_all_ports(docker_t)
|
||||
|
||||
files_read_config_files(docker_t)
|
||||
files_dontaudit_getattr_all_dirs(docker_t)
|
||||
files_dontaudit_getattr_all_files(docker_t)
|
||||
|
||||
fs_read_cgroup_files(docker_t)
|
||||
fs_read_tmpfs_symlinks(docker_t)
|
||||
fs_search_all(docker_t)
|
||||
fs_getattr_all_fs(docker_t)
|
||||
|
||||
storage_raw_rw_fixed_disk(docker_t)
|
||||
|
||||
auth_use_nsswitch(docker_t)
|
||||
auth_dontaudit_getattr_shadow(docker_t)
|
||||
|
||||
init_read_state(docker_t)
|
||||
init_status(docker_t)
|
||||
|
||||
logging_send_audit_msgs(docker_t)
|
||||
logging_send_syslog_msg(docker_t)
|
||||
|
||||
miscfiles_read_localization(docker_t)
|
||||
|
||||
mount_domtrans(docker_t)
|
||||
|
||||
seutil_read_default_contexts(docker_t)
|
||||
seutil_read_config(docker_t)
|
||||
|
||||
sysnet_dns_name_resolve(docker_t)
|
||||
sysnet_exec_ifconfig(docker_t)
|
||||
|
||||
optional_policy(`
|
||||
rpm_exec(docker_t)
|
||||
rpm_read_db(docker_t)
|
||||
rpm_exec(docker_t)
|
||||
')
|
||||
|
||||
optional_policy(`
|
||||
fstools_domtrans(docker_t)
|
||||
')
|
||||
|
||||
optional_policy(`
|
||||
iptables_domtrans(docker_t)
|
||||
')
|
||||
|
||||
optional_policy(`
|
||||
openvswitch_stream_connect(docker_t)
|
||||
')
|
||||
|
||||
#
|
||||
# lxc rules
|
||||
#
|
||||
|
||||
allow docker_t self:capability { dac_override setgid setpcap setuid sys_admin sys_boot sys_chroot sys_ptrace };
|
||||
|
||||
allow docker_t self:process { getcap setcap setexec setpgid setsched signal_perms };
|
||||
|
||||
allow docker_t self:netlink_route_socket rw_netlink_socket_perms;;
|
||||
allow docker_t self:netlink_audit_socket create_netlink_socket_perms;
|
||||
allow docker_t self:unix_dgram_socket { create_socket_perms sendto };
|
||||
allow docker_t self:unix_stream_socket { create_stream_socket_perms connectto };
|
||||
|
||||
allow docker_t docker_var_lib_t:dir mounton;
|
||||
allow docker_t docker_var_lib_t:chr_file mounton;
|
||||
can_exec(docker_t, docker_var_lib_t)
|
||||
|
||||
kernel_dontaudit_setsched(docker_t)
|
||||
kernel_get_sysvipc_info(docker_t)
|
||||
kernel_request_load_module(docker_t)
|
||||
kernel_mounton_messages(docker_t)
|
||||
kernel_mounton_all_proc(docker_t)
|
||||
kernel_mounton_all_sysctls(docker_t)
|
||||
kernel_unlabeled_entry_type(spc_t)
|
||||
kernel_unlabeled_domtrans(docker_t, spc_t)
|
||||
|
||||
dev_getattr_all(docker_t)
|
||||
dev_getattr_sysfs_fs(docker_t)
|
||||
dev_read_urand(docker_t)
|
||||
dev_read_lvm_control(docker_t)
|
||||
dev_rw_sysfs(docker_t)
|
||||
dev_rw_loop_control(docker_t)
|
||||
dev_rw_lvm_control(docker_t)
|
||||
|
||||
files_getattr_isid_type_dirs(docker_t)
|
||||
files_manage_isid_type_dirs(docker_t)
|
||||
files_manage_isid_type_files(docker_t)
|
||||
files_manage_isid_type_symlinks(docker_t)
|
||||
files_manage_isid_type_chr_files(docker_t)
|
||||
files_manage_isid_type_blk_files(docker_t)
|
||||
files_exec_isid_files(docker_t)
|
||||
files_mounton_isid(docker_t)
|
||||
files_mounton_non_security(docker_t)
|
||||
files_mounton_isid_type_chr_file(docker_t)
|
||||
|
||||
fs_mount_all_fs(docker_t)
|
||||
fs_unmount_all_fs(docker_t)
|
||||
fs_remount_all_fs(docker_t)
|
||||
files_mounton_isid(docker_t)
|
||||
fs_manage_cgroup_dirs(docker_t)
|
||||
fs_manage_cgroup_files(docker_t)
|
||||
fs_relabelfrom_xattr_fs(docker_t)
|
||||
fs_relabelfrom_tmpfs(docker_t)
|
||||
fs_read_tmpfs_symlinks(docker_t)
|
||||
fs_list_hugetlbfs(docker_t)
|
||||
|
||||
term_use_generic_ptys(docker_t)
|
||||
term_use_ptmx(docker_t)
|
||||
term_getattr_pty_fs(docker_t)
|
||||
term_relabel_pty_fs(docker_t)
|
||||
term_mounton_unallocated_ttys(docker_t)
|
||||
|
||||
modutils_domtrans_insmod(docker_t)
|
||||
|
||||
systemd_status_all_unit_files(docker_t)
|
||||
systemd_start_systemd_services(docker_t)
|
||||
|
||||
userdom_stream_connect(docker_t)
|
||||
userdom_search_user_home_content(docker_t)
|
||||
userdom_read_all_users_state(docker_t)
|
||||
userdom_relabel_user_home_files(docker_t)
|
||||
userdom_relabel_user_tmp_files(docker_t)
|
||||
userdom_relabel_user_tmp_dirs(docker_t)
|
||||
|
||||
optional_policy(`
|
||||
gpm_getattr_gpmctl(docker_t)
|
||||
')
|
||||
|
||||
optional_policy(`
|
||||
dbus_system_bus_client(docker_t)
|
||||
init_dbus_chat(docker_t)
|
||||
init_start_transient_unit(docker_t)
|
||||
|
||||
optional_policy(`
|
||||
systemd_dbus_chat_logind(docker_t)
|
||||
systemd_dbus_chat_machined(docker_t)
|
||||
')
|
||||
|
||||
optional_policy(`
|
||||
firewalld_dbus_chat(docker_t)
|
||||
')
|
||||
')
|
||||
|
||||
optional_policy(`
|
||||
udev_read_db(docker_t)
|
||||
')
|
||||
|
||||
optional_policy(`
|
||||
unconfined_domain(docker_t)
|
||||
unconfined_typebounds(docker_t)
|
||||
')
|
||||
|
||||
optional_policy(`
|
||||
virt_read_config(docker_t)
|
||||
virt_exec(docker_t)
|
||||
virt_stream_connect(docker_t)
|
||||
virt_stream_connect_sandbox(docker_t)
|
||||
virt_exec_sandbox_files(docker_t)
|
||||
virt_manage_sandbox_files(docker_t)
|
||||
virt_relabel_sandbox_filesystem(docker_t)
|
||||
# for lxc
|
||||
virt_transition_svirt_sandbox(docker_t, system_r)
|
||||
virt_mounton_sandbox_file(docker_t)
|
||||
# virt_attach_sandbox_tun_iface(docker_t)
|
||||
allow docker_t svirt_sandbox_domain:tun_socket relabelfrom;
|
||||
virt_sandbox_entrypoint(docker_t)
|
||||
')
|
||||
|
||||
tunable_policy(`docker_connect_any',`
|
||||
corenet_tcp_connect_all_ports(docker_t)
|
||||
corenet_sendrecv_all_packets(docker_t)
|
||||
corenet_tcp_sendrecv_all_ports(docker_t)
|
||||
')
|
||||
|
||||
########################################
|
||||
#
|
||||
# spc local policy
|
||||
#
|
||||
allow spc_t { docker_var_lib_t docker_share_t }:file entrypoint;
|
||||
role system_r types spc_t;
|
||||
|
||||
domtrans_pattern(docker_t, docker_share_t, spc_t)
|
||||
domtrans_pattern(docker_t, docker_var_lib_t, spc_t)
|
||||
allow docker_t spc_t:process { setsched signal_perms };
|
||||
ps_process_pattern(docker_t, spc_t)
|
||||
allow docker_t spc_t:socket_class_set { relabelto relabelfrom };
|
||||
filetrans_pattern(docker_t, docker_var_lib_t, docker_share_t, dir, "overlay")
|
||||
|
||||
optional_policy(`
|
||||
systemd_dbus_chat_machined(spc_t)
|
||||
')
|
||||
|
||||
optional_policy(`
|
||||
dbus_chat_system_bus(spc_t)
|
||||
')
|
||||
|
||||
optional_policy(`
|
||||
unconfined_domain_noaudit(spc_t)
|
||||
')
|
||||
|
||||
optional_policy(`
|
||||
virt_transition_svirt_sandbox(spc_t, system_r)
|
||||
virt_sandbox_entrypoint(spc_t)
|
||||
')
|
||||
|
||||
########################################
|
||||
#
|
||||
# docker_auth local policy
|
||||
#
|
||||
allow docker_auth_t self:fifo_file rw_fifo_file_perms;
|
||||
allow docker_auth_t self:unix_stream_socket create_stream_socket_perms;
|
||||
dontaudit docker_auth_t self:capability net_admin;
|
||||
|
||||
docker_stream_connect(docker_auth_t)
|
||||
|
||||
manage_dirs_pattern(docker_auth_t, docker_plugin_var_run_t, docker_plugin_var_run_t)
|
||||
manage_files_pattern(docker_auth_t, docker_plugin_var_run_t, docker_plugin_var_run_t)
|
||||
manage_sock_files_pattern(docker_auth_t, docker_plugin_var_run_t, docker_plugin_var_run_t)
|
||||
manage_lnk_files_pattern(docker_auth_t, docker_plugin_var_run_t, docker_plugin_var_run_t)
|
||||
files_pid_filetrans(docker_auth_t, docker_plugin_var_run_t, { dir file lnk_file sock_file })
|
||||
|
||||
domain_use_interactive_fds(docker_auth_t)
|
||||
|
||||
kernel_read_net_sysctls(docker_auth_t)
|
||||
|
||||
auth_use_nsswitch(docker_auth_t)
|
||||
|
||||
files_read_etc_files(docker_auth_t)
|
||||
|
||||
miscfiles_read_localization(docker_auth_t)
|
||||
|
||||
sysnet_dns_name_resolve(docker_auth_t)
|
339
contrib/selinux-oraclelinux-7/docker-engine-selinux/LICENSE
Normal file
339
contrib/selinux-oraclelinux-7/docker-engine-selinux/LICENSE
Normal file
|
@ -0,0 +1,339 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
23
contrib/selinux-oraclelinux-7/docker-engine-selinux/Makefile
Normal file
23
contrib/selinux-oraclelinux-7/docker-engine-selinux/Makefile
Normal file
|
@ -0,0 +1,23 @@
|
|||
TARGETS?=docker
|
||||
MODULES?=${TARGETS:=.pp.bz2}
|
||||
SHAREDIR?=/usr/share
|
||||
|
||||
all: ${TARGETS:=.pp.bz2}
|
||||
|
||||
%.pp.bz2: %.pp
|
||||
@echo Compressing $^ -\> $@
|
||||
bzip2 -9 $^
|
||||
|
||||
%.pp: %.te
|
||||
make -f ${SHAREDIR}/selinux/devel/Makefile $@
|
||||
|
||||
clean:
|
||||
rm -f *~ *.tc *.pp *.pp.bz2
|
||||
rm -rf tmp *.tar.gz
|
||||
|
||||
man: install
|
||||
sepolicy manpage --domain ${TARGETS}_t
|
||||
|
||||
install:
|
||||
semodule -i ${TARGETS}
|
||||
|
|
@ -0,0 +1 @@
|
|||
SELinux policy for docker
|
|
@ -0,0 +1,33 @@
|
|||
/root/\.docker gen_context(system_u:object_r:docker_home_t,s0)
|
||||
|
||||
/usr/bin/docker -- gen_context(system_u:object_r:docker_exec_t,s0)
|
||||
/usr/bin/docker-novolume-plugin -- gen_context(system_u:object_r:docker_auth_exec_t,s0)
|
||||
/usr/lib/docker/docker-novolume-plugin -- gen_context(system_u:object_r:docker_auth_exec_t,s0)
|
||||
|
||||
/usr/lib/systemd/system/docker.service -- gen_context(system_u:object_r:docker_unit_file_t,s0)
|
||||
/usr/lib/systemd/system/docker-novolume-plugin.service -- gen_context(system_u:object_r:docker_unit_file_t,s0)
|
||||
|
||||
/etc/docker(/.*)? gen_context(system_u:object_r:docker_config_t,s0)
|
||||
|
||||
/var/lib/docker(/.*)? gen_context(system_u:object_r:docker_var_lib_t,s0)
|
||||
/var/lib/kublet(/.*)? gen_context(system_u:object_r:docker_var_lib_t,s0)
|
||||
/var/lib/docker/vfs(/.*)? gen_context(system_u:object_r:svirt_sandbox_file_t,s0)
|
||||
|
||||
/var/run/docker(/.*)? gen_context(system_u:object_r:docker_var_run_t,s0)
|
||||
/var/run/docker\.pid -- gen_context(system_u:object_r:docker_var_run_t,s0)
|
||||
/var/run/docker\.sock -s gen_context(system_u:object_r:docker_var_run_t,s0)
|
||||
/var/run/docker-client(/.*)? gen_context(system_u:object_r:docker_var_run_t,s0)
|
||||
/var/run/docker/plugins(/.*)? gen_context(system_u:object_r:docker_plugin_var_run_t,s0)
|
||||
|
||||
/var/lock/lxc(/.*)? gen_context(system_u:object_r:docker_lock_t,s0)
|
||||
|
||||
/var/log/lxc(/.*)? gen_context(system_u:object_r:docker_log_t,s0)
|
||||
|
||||
/var/lib/docker/init(/.*)? gen_context(system_u:object_r:docker_share_t,s0)
|
||||
/var/lib/docker/containers/.*/hosts gen_context(system_u:object_r:docker_share_t,s0)
|
||||
/var/lib/docker/containers/.*/hostname gen_context(system_u:object_r:docker_share_t,s0)
|
||||
/var/lib/docker/.*/config\.env gen_context(system_u:object_r:docker_share_t,s0)
|
||||
|
||||
# OL7.2 systemd selinux update
|
||||
/var/run/systemd/machines(/.*)? gen_context(system_u:object_r:systemd_machined_var_run_t,s0)
|
||||
/var/lib/machines(/.*)? gen_context(system_u:object_r:systemd_machined_var_lib_t,s0)
|
659
contrib/selinux-oraclelinux-7/docker-engine-selinux/docker.if
Normal file
659
contrib/selinux-oraclelinux-7/docker-engine-selinux/docker.if
Normal file
|
@ -0,0 +1,659 @@
|
|||
|
||||
## <summary>The open-source application container engine.</summary>
|
||||
|
||||
########################################
|
||||
## <summary>
|
||||
## Execute docker in the docker domain.
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed to transition.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`docker_domtrans',`
|
||||
gen_require(`
|
||||
type docker_t, docker_exec_t;
|
||||
')
|
||||
|
||||
corecmd_search_bin($1)
|
||||
domtrans_pattern($1, docker_exec_t, docker_t)
|
||||
')
|
||||
|
||||
########################################
|
||||
## <summary>
|
||||
## Execute docker in the caller domain.
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed to transition.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`docker_exec',`
|
||||
gen_require(`
|
||||
type docker_exec_t;
|
||||
')
|
||||
|
||||
corecmd_search_bin($1)
|
||||
can_exec($1, docker_exec_t)
|
||||
')
|
||||
|
||||
########################################
|
||||
## <summary>
|
||||
## Search docker lib directories.
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed access.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`docker_search_lib',`
|
||||
gen_require(`
|
||||
type docker_var_lib_t;
|
||||
')
|
||||
|
||||
allow $1 docker_var_lib_t:dir search_dir_perms;
|
||||
files_search_var_lib($1)
|
||||
')
|
||||
|
||||
########################################
|
||||
## <summary>
|
||||
## Execute docker lib directories.
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed access.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`docker_exec_lib',`
|
||||
gen_require(`
|
||||
type docker_var_lib_t;
|
||||
')
|
||||
|
||||
allow $1 docker_var_lib_t:dir search_dir_perms;
|
||||
can_exec($1, docker_var_lib_t)
|
||||
')
|
||||
|
||||
########################################
|
||||
## <summary>
|
||||
## Read docker lib files.
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed access.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`docker_read_lib_files',`
|
||||
gen_require(`
|
||||
type docker_var_lib_t;
|
||||
')
|
||||
|
||||
files_search_var_lib($1)
|
||||
read_files_pattern($1, docker_var_lib_t, docker_var_lib_t)
|
||||
')
|
||||
|
||||
########################################
|
||||
## <summary>
|
||||
## Read docker share files.
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed access.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`docker_read_share_files',`
|
||||
gen_require(`
|
||||
type docker_share_t;
|
||||
')
|
||||
|
||||
files_search_var_lib($1)
|
||||
list_dirs_pattern($1, docker_share_t, docker_share_t)
|
||||
read_files_pattern($1, docker_share_t, docker_share_t)
|
||||
read_lnk_files_pattern($1, docker_share_t, docker_share_t)
|
||||
')
|
||||
|
||||
######################################
|
||||
## <summary>
|
||||
## Allow the specified domain to execute docker shared files
|
||||
## in the caller domain.
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed access.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`docker_exec_share_files',`
|
||||
gen_require(`
|
||||
type docker_share_t;
|
||||
')
|
||||
|
||||
can_exec($1, docker_share_t)
|
||||
')
|
||||
|
||||
########################################
|
||||
## <summary>
|
||||
## Manage docker lib files.
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed access.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`docker_manage_lib_files',`
|
||||
gen_require(`
|
||||
type docker_var_lib_t;
|
||||
')
|
||||
|
||||
files_search_var_lib($1)
|
||||
manage_files_pattern($1, docker_var_lib_t, docker_var_lib_t)
|
||||
manage_lnk_files_pattern($1, docker_var_lib_t, docker_var_lib_t)
|
||||
')
|
||||
|
||||
########################################
|
||||
## <summary>
|
||||
## Manage docker lib directories.
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed access.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`docker_manage_lib_dirs',`
|
||||
gen_require(`
|
||||
type docker_var_lib_t;
|
||||
')
|
||||
|
||||
files_search_var_lib($1)
|
||||
manage_dirs_pattern($1, docker_var_lib_t, docker_var_lib_t)
|
||||
')
|
||||
|
||||
########################################
|
||||
## <summary>
|
||||
## Create objects in a docker var lib directory
|
||||
## with an automatic type transition to
|
||||
## a specified private type.
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed access.
|
||||
## </summary>
|
||||
## </param>
|
||||
## <param name="private_type">
|
||||
## <summary>
|
||||
## The type of the object to create.
|
||||
## </summary>
|
||||
## </param>
|
||||
## <param name="object_class">
|
||||
## <summary>
|
||||
## The class of the object to be created.
|
||||
## </summary>
|
||||
## </param>
|
||||
## <param name="name" optional="true">
|
||||
## <summary>
|
||||
## The name of the object being created.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`docker_lib_filetrans',`
|
||||
gen_require(`
|
||||
type docker_var_lib_t;
|
||||
')
|
||||
|
||||
filetrans_pattern($1, docker_var_lib_t, $2, $3, $4)
|
||||
')
|
||||
|
||||
########################################
|
||||
## <summary>
|
||||
## Read docker PID files.
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed access.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`docker_read_pid_files',`
|
||||
gen_require(`
|
||||
type docker_var_run_t;
|
||||
')
|
||||
|
||||
files_search_pids($1)
|
||||
read_files_pattern($1, docker_var_run_t, docker_var_run_t)
|
||||
')
|
||||
|
||||
########################################
|
||||
## <summary>
|
||||
## Execute docker server in the docker domain.
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed to transition.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`docker_systemctl',`
|
||||
gen_require(`
|
||||
type docker_t;
|
||||
type docker_unit_file_t;
|
||||
')
|
||||
|
||||
systemd_exec_systemctl($1)
|
||||
init_reload_services($1)
|
||||
systemd_read_fifo_file_passwd_run($1)
|
||||
allow $1 docker_unit_file_t:file read_file_perms;
|
||||
allow $1 docker_unit_file_t:service manage_service_perms;
|
||||
|
||||
ps_process_pattern($1, docker_t)
|
||||
')
|
||||
|
||||
########################################
|
||||
## <summary>
|
||||
## Read and write docker shared memory.
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed access.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`docker_rw_sem',`
|
||||
gen_require(`
|
||||
type docker_t;
|
||||
')
|
||||
|
||||
allow $1 docker_t:sem rw_sem_perms;
|
||||
')
|
||||
|
||||
#######################################
|
||||
## <summary>
|
||||
## Read and write the docker pty type.
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed access.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`docker_use_ptys',`
|
||||
gen_require(`
|
||||
type docker_devpts_t;
|
||||
')
|
||||
|
||||
allow $1 docker_devpts_t:chr_file rw_term_perms;
|
||||
')
|
||||
|
||||
#######################################
|
||||
## <summary>
|
||||
## Allow domain to create docker content
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed access.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`docker_filetrans_named_content',`
|
||||
|
||||
gen_require(`
|
||||
type docker_var_lib_t;
|
||||
type docker_share_t;
|
||||
type docker_log_t;
|
||||
type docker_var_run_t;
|
||||
type docker_home_t;
|
||||
')
|
||||
|
||||
files_pid_filetrans($1, docker_var_run_t, file, "docker.pid")
|
||||
files_pid_filetrans($1, docker_var_run_t, sock_file, "docker.sock")
|
||||
files_pid_filetrans($1, docker_var_run_t, dir, "docker-client")
|
||||
logging_log_filetrans($1, docker_log_t, dir, "lxc")
|
||||
files_var_lib_filetrans($1, docker_var_lib_t, dir, "docker")
|
||||
filetrans_pattern($1, docker_var_lib_t, docker_share_t, file, "config.env")
|
||||
filetrans_pattern($1, docker_var_lib_t, docker_share_t, file, "hosts")
|
||||
filetrans_pattern($1, docker_var_lib_t, docker_share_t, file, "hostname")
|
||||
filetrans_pattern($1, docker_var_lib_t, docker_share_t, file, "resolv.conf")
|
||||
filetrans_pattern($1, docker_var_lib_t, docker_share_t, dir, "init")
|
||||
userdom_admin_home_dir_filetrans($1, docker_home_t, dir, ".docker")
|
||||
')
|
||||
|
||||
########################################
|
||||
## <summary>
|
||||
## Connect to docker over a unix stream socket.
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed access.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`docker_stream_connect',`
|
||||
gen_require(`
|
||||
type docker_t, docker_var_run_t;
|
||||
')
|
||||
|
||||
files_search_pids($1)
|
||||
stream_connect_pattern($1, docker_var_run_t, docker_var_run_t, docker_t)
|
||||
')
|
||||
|
||||
########################################
|
||||
## <summary>
|
||||
## Connect to SPC containers over a unix stream socket.
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed access.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`docker_spc_stream_connect',`
|
||||
gen_require(`
|
||||
type spc_t, spc_var_run_t;
|
||||
')
|
||||
|
||||
files_search_pids($1)
|
||||
files_write_all_pid_sockets($1)
|
||||
allow $1 spc_t:unix_stream_socket connectto;
|
||||
')
|
||||
|
||||
########################################
|
||||
## <summary>
|
||||
## All of the rules required to administrate
|
||||
## an docker environment
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed access.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`docker_admin',`
|
||||
gen_require(`
|
||||
type docker_t;
|
||||
type docker_var_lib_t, docker_var_run_t;
|
||||
type docker_unit_file_t;
|
||||
type docker_lock_t;
|
||||
type docker_log_t;
|
||||
type docker_config_t;
|
||||
')
|
||||
|
||||
allow $1 docker_t:process { ptrace signal_perms };
|
||||
ps_process_pattern($1, docker_t)
|
||||
|
||||
admin_pattern($1, docker_config_t)
|
||||
|
||||
files_search_var_lib($1)
|
||||
admin_pattern($1, docker_var_lib_t)
|
||||
|
||||
files_search_pids($1)
|
||||
admin_pattern($1, docker_var_run_t)
|
||||
|
||||
files_search_locks($1)
|
||||
admin_pattern($1, docker_lock_t)
|
||||
|
||||
logging_search_logs($1)
|
||||
admin_pattern($1, docker_log_t)
|
||||
|
||||
docker_systemctl($1)
|
||||
admin_pattern($1, docker_unit_file_t)
|
||||
allow $1 docker_unit_file_t:service all_service_perms;
|
||||
|
||||
optional_policy(`
|
||||
systemd_passwd_agent_exec($1)
|
||||
systemd_read_fifo_file_passwd_run($1)
|
||||
')
|
||||
')
|
||||
|
||||
########################################
|
||||
## <summary>
|
||||
## Execute docker_auth_exec_t in the docker_auth domain.
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed to transition.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`docker_auth_domtrans',`
|
||||
gen_require(`
|
||||
type docker_auth_t, docker_auth_exec_t;
|
||||
')
|
||||
|
||||
corecmd_search_bin($1)
|
||||
domtrans_pattern($1, docker_auth_exec_t, docker_auth_t)
|
||||
')
|
||||
|
||||
######################################
|
||||
## <summary>
|
||||
## Execute docker_auth in the caller domain.
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed access.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`docker_auth_exec',`
|
||||
gen_require(`
|
||||
type docker_auth_exec_t;
|
||||
')
|
||||
|
||||
corecmd_search_bin($1)
|
||||
can_exec($1, docker_auth_exec_t)
|
||||
')
|
||||
|
||||
########################################
|
||||
## <summary>
|
||||
## Connect to docker_auth over a unix stream socket.
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed access.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`docker_auth_stream_connect',`
|
||||
gen_require(`
|
||||
type docker_auth_t, docker_plugin_var_run_t;
|
||||
')
|
||||
|
||||
files_search_pids($1)
|
||||
stream_connect_pattern($1, docker_plugin_var_run_t, docker_plugin_var_run_t, docker_auth_t)
|
||||
')
|
||||
|
||||
########################################
|
||||
## <summary>
|
||||
## docker domain typebounds calling domain.
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain to be typebound.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`docker_typebounds',`
|
||||
gen_require(`
|
||||
type docker_t;
|
||||
')
|
||||
|
||||
typebounds docker_t $1;
|
||||
')
|
||||
|
||||
########################################
|
||||
## <summary>
|
||||
## Allow any docker_exec_t to be an entrypoint of this domain
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed access.
|
||||
## </summary>
|
||||
## </param>
|
||||
## <rolecap/>
|
||||
#
|
||||
interface(`docker_entrypoint',`
|
||||
gen_require(`
|
||||
type docker_exec_t;
|
||||
')
|
||||
allow $1 docker_exec_t:file entrypoint;
|
||||
')
|
||||
|
||||
########################################
|
||||
## <summary>
|
||||
## Send and receive messages from
|
||||
## systemd machined over dbus.
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed access.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`systemd_dbus_chat_machined',`
|
||||
gen_require(`
|
||||
type systemd_machined_t;
|
||||
class dbus send_msg;
|
||||
')
|
||||
|
||||
allow $1 systemd_machined_t:dbus send_msg;
|
||||
allow systemd_machined_t $1:dbus send_msg;
|
||||
ps_process_pattern(systemd_machined_t, $1)
|
||||
')
|
||||
|
||||
########################################
|
||||
## <summary>
|
||||
## Allow any svirt_sandbox_file_t to be an entrypoint of this domain
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed access.
|
||||
## </summary>
|
||||
## </param>
|
||||
## <rolecap/>
|
||||
#
|
||||
interface(`virt_sandbox_entrypoint',`
|
||||
gen_require(`
|
||||
type svirt_sandbox_file_t;
|
||||
')
|
||||
allow $1 svirt_sandbox_file_t:file entrypoint;
|
||||
')
|
||||
|
||||
########################################
|
||||
## <summary>
|
||||
## Send and receive messages from
|
||||
## virt over dbus.
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed access.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`virt_dbus_chat',`
|
||||
gen_require(`
|
||||
type virtd_t;
|
||||
class dbus send_msg;
|
||||
')
|
||||
|
||||
allow $1 virtd_t:dbus send_msg;
|
||||
allow virtd_t $1:dbus send_msg;
|
||||
ps_process_pattern(virtd_t, $1)
|
||||
')
|
||||
|
||||
#######################################
|
||||
## <summary>
|
||||
## Read the process state of virt sandbox containers
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed access.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`virt_sandbox_read_state',`
|
||||
gen_require(`
|
||||
attribute svirt_sandbox_domain;
|
||||
')
|
||||
|
||||
ps_process_pattern($1, svirt_sandbox_domain)
|
||||
')
|
||||
|
||||
######################################
|
||||
## <summary>
|
||||
## Send a signal to sandbox domains
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed access.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`virt_signal_sandbox',`
|
||||
gen_require(`
|
||||
attribute svirt_sandbox_domain;
|
||||
')
|
||||
|
||||
allow $1 svirt_sandbox_domain:process signal;
|
||||
')
|
||||
|
||||
#######################################
|
||||
## <summary>
|
||||
## Getattr Sandbox File systems
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed access.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`virt_getattr_sandbox_filesystem',`
|
||||
gen_require(`
|
||||
type svirt_sandbox_file_t;
|
||||
')
|
||||
|
||||
allow $1 svirt_sandbox_file_t:filesystem getattr;
|
||||
')
|
||||
|
||||
#######################################
|
||||
## <summary>
|
||||
## Read Sandbox Files
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed access.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`virt_read_sandbox_files',`
|
||||
gen_require(`
|
||||
type svirt_sandbox_file_t;
|
||||
')
|
||||
|
||||
list_dirs_pattern($1, svirt_sandbox_file_t, svirt_sandbox_file_t)
|
||||
read_files_pattern($1, svirt_sandbox_file_t, svirt_sandbox_file_t)
|
||||
read_lnk_files_pattern($1, svirt_sandbox_file_t, svirt_sandbox_file_t)
|
||||
')
|
||||
|
||||
#######################################
|
||||
## <summary>
|
||||
## Read the process state of spc containers
|
||||
## </summary>
|
||||
## <param name="domain">
|
||||
## <summary>
|
||||
## Domain allowed access.
|
||||
## </summary>
|
||||
## </param>
|
||||
#
|
||||
interface(`docker_spc_read_state',`
|
||||
gen_require(`
|
||||
type spc_t;
|
||||
')
|
||||
|
||||
ps_process_pattern($1, spc_t)
|
||||
')
|
||||
|
465
contrib/selinux-oraclelinux-7/docker-engine-selinux/docker.te
Normal file
465
contrib/selinux-oraclelinux-7/docker-engine-selinux/docker.te
Normal file
|
@ -0,0 +1,465 @@
|
|||
policy_module(docker, 1.0.0)
|
||||
|
||||
########################################
|
||||
#
|
||||
# Declarations
|
||||
#
|
||||
|
||||
## <desc>
|
||||
## <p>
|
||||
## Determine whether docker can
|
||||
## connect to all TCP ports.
|
||||
## </p>
|
||||
## </desc>
|
||||
gen_tunable(docker_connect_any, false)
|
||||
|
||||
type docker_t;
|
||||
type docker_exec_t;
|
||||
init_daemon_domain(docker_t, docker_exec_t)
|
||||
domain_subj_id_change_exemption(docker_t)
|
||||
domain_role_change_exemption(docker_t)
|
||||
|
||||
type spc_t;
|
||||
domain_type(spc_t)
|
||||
role system_r types spc_t;
|
||||
|
||||
type docker_auth_t;
|
||||
type docker_auth_exec_t;
|
||||
init_daemon_domain(docker_auth_t, docker_auth_exec_t)
|
||||
|
||||
type spc_var_run_t;
|
||||
files_pid_file(spc_var_run_t)
|
||||
|
||||
type docker_var_lib_t;
|
||||
files_type(docker_var_lib_t)
|
||||
|
||||
type docker_home_t;
|
||||
userdom_user_home_content(docker_home_t)
|
||||
|
||||
type docker_config_t;
|
||||
files_config_file(docker_config_t)
|
||||
|
||||
type docker_lock_t;
|
||||
files_lock_file(docker_lock_t)
|
||||
|
||||
type docker_log_t;
|
||||
logging_log_file(docker_log_t)
|
||||
|
||||
type docker_tmp_t;
|
||||
files_tmp_file(docker_tmp_t)
|
||||
|
||||
type docker_tmpfs_t;
|
||||
files_tmpfs_file(docker_tmpfs_t)
|
||||
|
||||
type docker_var_run_t;
|
||||
files_pid_file(docker_var_run_t)
|
||||
|
||||
type docker_plugin_var_run_t;
|
||||
files_pid_file(docker_plugin_var_run_t)
|
||||
|
||||
type docker_unit_file_t;
|
||||
systemd_unit_file(docker_unit_file_t)
|
||||
|
||||
type docker_devpts_t;
|
||||
term_pty(docker_devpts_t)
|
||||
|
||||
type docker_share_t;
|
||||
files_type(docker_share_t)
|
||||
|
||||
# OL7 systemd selinux update
|
||||
type systemd_machined_t;
|
||||
type systemd_machined_exec_t;
|
||||
init_daemon_domain(systemd_machined_t, systemd_machined_exec_t)
|
||||
|
||||
# /run/systemd/machines
|
||||
type systemd_machined_var_run_t;
|
||||
files_pid_file(systemd_machined_var_run_t)
|
||||
|
||||
# /var/lib/machines
|
||||
type systemd_machined_var_lib_t;
|
||||
files_type(systemd_machined_var_lib_t)
|
||||
|
||||
|
||||
########################################
|
||||
#
|
||||
# docker local policy
|
||||
#
|
||||
allow docker_t self:capability { chown kill fowner fsetid mknod net_admin net_bind_service net_raw setfcap };
|
||||
allow docker_t self:tun_socket relabelto;
|
||||
allow docker_t self:process { getattr signal_perms setrlimit setfscreate };
|
||||
allow docker_t self:fifo_file rw_fifo_file_perms;
|
||||
allow docker_t self:unix_stream_socket create_stream_socket_perms;
|
||||
allow docker_t self:tcp_socket create_stream_socket_perms;
|
||||
allow docker_t self:udp_socket create_socket_perms;
|
||||
allow docker_t self:capability2 block_suspend;
|
||||
|
||||
docker_auth_stream_connect(docker_t)
|
||||
|
||||
manage_files_pattern(docker_t, docker_home_t, docker_home_t)
|
||||
manage_dirs_pattern(docker_t, docker_home_t, docker_home_t)
|
||||
manage_lnk_files_pattern(docker_t, docker_home_t, docker_home_t)
|
||||
userdom_admin_home_dir_filetrans(docker_t, docker_home_t, dir, ".docker")
|
||||
|
||||
manage_dirs_pattern(docker_t, docker_config_t, docker_config_t)
|
||||
manage_files_pattern(docker_t, docker_config_t, docker_config_t)
|
||||
files_etc_filetrans(docker_t, docker_config_t, dir, "docker")
|
||||
|
||||
manage_dirs_pattern(docker_t, docker_lock_t, docker_lock_t)
|
||||
manage_files_pattern(docker_t, docker_lock_t, docker_lock_t)
|
||||
files_lock_filetrans(docker_t, docker_lock_t, { dir file }, "lxc")
|
||||
|
||||
manage_dirs_pattern(docker_t, docker_log_t, docker_log_t)
|
||||
manage_files_pattern(docker_t, docker_log_t, docker_log_t)
|
||||
manage_lnk_files_pattern(docker_t, docker_log_t, docker_log_t)
|
||||
logging_log_filetrans(docker_t, docker_log_t, { dir file lnk_file })
|
||||
allow docker_t docker_log_t:dir_file_class_set { relabelfrom relabelto };
|
||||
|
||||
manage_dirs_pattern(docker_t, docker_tmp_t, docker_tmp_t)
|
||||
manage_files_pattern(docker_t, docker_tmp_t, docker_tmp_t)
|
||||
manage_lnk_files_pattern(docker_t, docker_tmp_t, docker_tmp_t)
|
||||
files_tmp_filetrans(docker_t, docker_tmp_t, { dir file lnk_file })
|
||||
|
||||
manage_dirs_pattern(docker_t, docker_tmpfs_t, docker_tmpfs_t)
|
||||
manage_files_pattern(docker_t, docker_tmpfs_t, docker_tmpfs_t)
|
||||
manage_lnk_files_pattern(docker_t, docker_tmpfs_t, docker_tmpfs_t)
|
||||
manage_fifo_files_pattern(docker_t, docker_tmpfs_t, docker_tmpfs_t)
|
||||
manage_chr_files_pattern(docker_t, docker_tmpfs_t, docker_tmpfs_t)
|
||||
manage_blk_files_pattern(docker_t, docker_tmpfs_t, docker_tmpfs_t)
|
||||
allow docker_t docker_tmpfs_t:dir relabelfrom;
|
||||
can_exec(docker_t, docker_tmpfs_t)
|
||||
fs_tmpfs_filetrans(docker_t, docker_tmpfs_t, { dir file })
|
||||
allow docker_t docker_tmpfs_t:chr_file mounton;
|
||||
|
||||
manage_dirs_pattern(docker_t, docker_share_t, docker_share_t)
|
||||
manage_files_pattern(docker_t, docker_share_t, docker_share_t)
|
||||
manage_lnk_files_pattern(docker_t, docker_share_t, docker_share_t)
|
||||
allow docker_t docker_share_t:dir_file_class_set { relabelfrom relabelto };
|
||||
|
||||
can_exec(docker_t, docker_share_t)
|
||||
#docker_filetrans_named_content(docker_t)
|
||||
|
||||
manage_dirs_pattern(docker_t, docker_var_lib_t, docker_var_lib_t)
|
||||
manage_chr_files_pattern(docker_t, docker_var_lib_t, docker_var_lib_t)
|
||||
manage_blk_files_pattern(docker_t, docker_var_lib_t, docker_var_lib_t)
|
||||
manage_files_pattern(docker_t, docker_var_lib_t, docker_var_lib_t)
|
||||
manage_lnk_files_pattern(docker_t, docker_var_lib_t, docker_var_lib_t)
|
||||
allow docker_t docker_var_lib_t:dir_file_class_set { relabelfrom relabelto };
|
||||
files_var_lib_filetrans(docker_t, docker_var_lib_t, { dir file lnk_file })
|
||||
|
||||
manage_dirs_pattern(docker_t, docker_var_run_t, docker_var_run_t)
|
||||
manage_files_pattern(docker_t, docker_var_run_t, docker_var_run_t)
|
||||
manage_sock_files_pattern(docker_t, docker_var_run_t, docker_var_run_t)
|
||||
manage_lnk_files_pattern(docker_t, docker_var_run_t, docker_var_run_t)
|
||||
files_pid_filetrans(docker_t, docker_var_run_t, { dir file lnk_file sock_file })
|
||||
|
||||
allow docker_t docker_devpts_t:chr_file { relabelfrom rw_chr_file_perms setattr_chr_file_perms };
|
||||
term_create_pty(docker_t, docker_devpts_t)
|
||||
|
||||
kernel_read_system_state(docker_t)
|
||||
kernel_read_network_state(docker_t)
|
||||
kernel_read_all_sysctls(docker_t)
|
||||
kernel_rw_net_sysctls(docker_t)
|
||||
kernel_setsched(docker_t)
|
||||
kernel_read_all_proc(docker_t)
|
||||
|
||||
domain_use_interactive_fds(docker_t)
|
||||
domain_dontaudit_read_all_domains_state(docker_t)
|
||||
|
||||
corecmd_exec_bin(docker_t)
|
||||
corecmd_exec_shell(docker_t)
|
||||
|
||||
corenet_tcp_bind_generic_node(docker_t)
|
||||
corenet_tcp_sendrecv_generic_if(docker_t)
|
||||
corenet_tcp_sendrecv_generic_node(docker_t)
|
||||
corenet_tcp_sendrecv_generic_port(docker_t)
|
||||
corenet_tcp_bind_all_ports(docker_t)
|
||||
corenet_tcp_connect_http_port(docker_t)
|
||||
corenet_tcp_connect_commplex_main_port(docker_t)
|
||||
corenet_udp_sendrecv_generic_if(docker_t)
|
||||
corenet_udp_sendrecv_generic_node(docker_t)
|
||||
corenet_udp_sendrecv_all_ports(docker_t)
|
||||
corenet_udp_bind_generic_node(docker_t)
|
||||
corenet_udp_bind_all_ports(docker_t)
|
||||
|
||||
files_read_config_files(docker_t)
|
||||
files_dontaudit_getattr_all_dirs(docker_t)
|
||||
files_dontaudit_getattr_all_files(docker_t)
|
||||
|
||||
fs_read_cgroup_files(docker_t)
|
||||
fs_read_tmpfs_symlinks(docker_t)
|
||||
fs_search_all(docker_t)
|
||||
fs_getattr_all_fs(docker_t)
|
||||
|
||||
storage_raw_rw_fixed_disk(docker_t)
|
||||
|
||||
auth_use_nsswitch(docker_t)
|
||||
auth_dontaudit_getattr_shadow(docker_t)
|
||||
|
||||
init_read_state(docker_t)
|
||||
init_status(docker_t)
|
||||
|
||||
logging_send_audit_msgs(docker_t)
|
||||
logging_send_syslog_msg(docker_t)
|
||||
|
||||
miscfiles_read_localization(docker_t)
|
||||
|
||||
mount_domtrans(docker_t)
|
||||
|
||||
seutil_read_default_contexts(docker_t)
|
||||
seutil_read_config(docker_t)
|
||||
|
||||
sysnet_dns_name_resolve(docker_t)
|
||||
sysnet_exec_ifconfig(docker_t)
|
||||
|
||||
optional_policy(`
|
||||
rpm_exec(docker_t)
|
||||
rpm_read_db(docker_t)
|
||||
rpm_exec(docker_t)
|
||||
')
|
||||
|
||||
optional_policy(`
|
||||
fstools_domtrans(docker_t)
|
||||
')
|
||||
|
||||
optional_policy(`
|
||||
iptables_domtrans(docker_t)
|
||||
')
|
||||
|
||||
optional_policy(`
|
||||
openvswitch_stream_connect(docker_t)
|
||||
')
|
||||
|
||||
#
|
||||
# lxc rules
|
||||
#
|
||||
|
||||
allow docker_t self:capability { dac_override setgid setpcap setuid sys_admin sys_boot sys_chroot sys_ptrace };
|
||||
|
||||
allow docker_t self:process { getcap setcap setexec setpgid setsched signal_perms };
|
||||
|
||||
allow docker_t self:netlink_route_socket rw_netlink_socket_perms;;
|
||||
allow docker_t self:netlink_audit_socket create_netlink_socket_perms;
|
||||
allow docker_t self:unix_dgram_socket { create_socket_perms sendto };
|
||||
allow docker_t self:unix_stream_socket { create_stream_socket_perms connectto };
|
||||
|
||||
allow docker_t docker_var_lib_t:dir mounton;
|
||||
allow docker_t docker_var_lib_t:chr_file mounton;
|
||||
can_exec(docker_t, docker_var_lib_t)
|
||||
|
||||
kernel_dontaudit_setsched(docker_t)
|
||||
kernel_get_sysvipc_info(docker_t)
|
||||
kernel_request_load_module(docker_t)
|
||||
kernel_mounton_messages(docker_t)
|
||||
kernel_mounton_all_proc(docker_t)
|
||||
kernel_mounton_all_sysctls(docker_t)
|
||||
kernel_unlabeled_entry_type(spc_t)
|
||||
kernel_unlabeled_domtrans(docker_t, spc_t)
|
||||
|
||||
dev_getattr_all(docker_t)
|
||||
dev_getattr_sysfs_fs(docker_t)
|
||||
dev_read_urand(docker_t)
|
||||
dev_read_lvm_control(docker_t)
|
||||
dev_rw_sysfs(docker_t)
|
||||
dev_rw_loop_control(docker_t)
|
||||
dev_rw_lvm_control(docker_t)
|
||||
|
||||
files_getattr_isid_type_dirs(docker_t)
|
||||
files_manage_isid_type_dirs(docker_t)
|
||||
files_manage_isid_type_files(docker_t)
|
||||
files_manage_isid_type_symlinks(docker_t)
|
||||
files_manage_isid_type_chr_files(docker_t)
|
||||
files_manage_isid_type_blk_files(docker_t)
|
||||
files_exec_isid_files(docker_t)
|
||||
files_mounton_isid(docker_t)
|
||||
files_mounton_non_security(docker_t)
|
||||
files_mounton_isid_type_chr_file(docker_t)
|
||||
|
||||
fs_mount_all_fs(docker_t)
|
||||
fs_unmount_all_fs(docker_t)
|
||||
fs_remount_all_fs(docker_t)
|
||||
files_mounton_isid(docker_t)
|
||||
fs_manage_cgroup_dirs(docker_t)
|
||||
fs_manage_cgroup_files(docker_t)
|
||||
fs_relabelfrom_xattr_fs(docker_t)
|
||||
fs_relabelfrom_tmpfs(docker_t)
|
||||
fs_read_tmpfs_symlinks(docker_t)
|
||||
fs_list_hugetlbfs(docker_t)
|
||||
|
||||
term_use_generic_ptys(docker_t)
|
||||
term_use_ptmx(docker_t)
|
||||
term_getattr_pty_fs(docker_t)
|
||||
term_relabel_pty_fs(docker_t)
|
||||
term_mounton_unallocated_ttys(docker_t)
|
||||
|
||||
modutils_domtrans_insmod(docker_t)
|
||||
|
||||
systemd_status_all_unit_files(docker_t)
|
||||
systemd_start_systemd_services(docker_t)
|
||||
|
||||
userdom_stream_connect(docker_t)
|
||||
userdom_search_user_home_content(docker_t)
|
||||
userdom_read_all_users_state(docker_t)
|
||||
userdom_relabel_user_home_files(docker_t)
|
||||
userdom_relabel_user_tmp_files(docker_t)
|
||||
userdom_relabel_user_tmp_dirs(docker_t)
|
||||
|
||||
optional_policy(`
|
||||
gpm_getattr_gpmctl(docker_t)
|
||||
')
|
||||
|
||||
optional_policy(`
|
||||
dbus_system_bus_client(docker_t)
|
||||
init_dbus_chat(docker_t)
|
||||
init_start_transient_unit(docker_t)
|
||||
|
||||
optional_policy(`
|
||||
systemd_dbus_chat_logind(docker_t)
|
||||
systemd_dbus_chat_machined(docker_t)
|
||||
')
|
||||
|
||||
optional_policy(`
|
||||
firewalld_dbus_chat(docker_t)
|
||||
')
|
||||
')
|
||||
|
||||
optional_policy(`
|
||||
udev_read_db(docker_t)
|
||||
')
|
||||
|
||||
optional_policy(`
|
||||
unconfined_domain(docker_t)
|
||||
# unconfined_typebounds(docker_t)
|
||||
')
|
||||
|
||||
optional_policy(`
|
||||
virt_read_config(docker_t)
|
||||
virt_exec(docker_t)
|
||||
virt_stream_connect(docker_t)
|
||||
virt_stream_connect_sandbox(docker_t)
|
||||
virt_exec_sandbox_files(docker_t)
|
||||
virt_manage_sandbox_files(docker_t)
|
||||
virt_relabel_sandbox_filesystem(docker_t)
|
||||
# for lxc
|
||||
virt_transition_svirt_sandbox(docker_t, system_r)
|
||||
virt_mounton_sandbox_file(docker_t)
|
||||
# virt_attach_sandbox_tun_iface(docker_t)
|
||||
allow docker_t svirt_sandbox_domain:tun_socket relabelfrom;
|
||||
virt_sandbox_entrypoint(docker_t)
|
||||
')
|
||||
|
||||
tunable_policy(`docker_connect_any',`
|
||||
corenet_tcp_connect_all_ports(docker_t)
|
||||
corenet_sendrecv_all_packets(docker_t)
|
||||
corenet_tcp_sendrecv_all_ports(docker_t)
|
||||
')
|
||||
|
||||
########################################
|
||||
#
|
||||
# spc local policy
|
||||
#
|
||||
allow spc_t { docker_var_lib_t docker_share_t }:file entrypoint;
|
||||
role system_r types spc_t;
|
||||
|
||||
domtrans_pattern(docker_t, docker_share_t, spc_t)
|
||||
domtrans_pattern(docker_t, docker_var_lib_t, spc_t)
|
||||
allow docker_t spc_t:process { setsched signal_perms };
|
||||
ps_process_pattern(docker_t, spc_t)
|
||||
allow docker_t spc_t:socket_class_set { relabelto relabelfrom };
|
||||
filetrans_pattern(docker_t, docker_var_lib_t, docker_share_t, dir, "overlay")
|
||||
|
||||
optional_policy(`
|
||||
systemd_dbus_chat_machined(spc_t)
|
||||
')
|
||||
|
||||
optional_policy(`
|
||||
dbus_chat_system_bus(spc_t)
|
||||
')
|
||||
|
||||
optional_policy(`
|
||||
unconfined_domain_noaudit(spc_t)
|
||||
')
|
||||
|
||||
optional_policy(`
|
||||
virt_transition_svirt_sandbox(spc_t, system_r)
|
||||
virt_sandbox_entrypoint(spc_t)
|
||||
')
|
||||
|
||||
########################################
|
||||
#
|
||||
# docker_auth local policy
|
||||
#
|
||||
allow docker_auth_t self:fifo_file rw_fifo_file_perms;
|
||||
allow docker_auth_t self:unix_stream_socket create_stream_socket_perms;
|
||||
dontaudit docker_auth_t self:capability net_admin;
|
||||
|
||||
docker_stream_connect(docker_auth_t)
|
||||
|
||||
manage_dirs_pattern(docker_auth_t, docker_plugin_var_run_t, docker_plugin_var_run_t)
|
||||
manage_files_pattern(docker_auth_t, docker_plugin_var_run_t, docker_plugin_var_run_t)
|
||||
manage_sock_files_pattern(docker_auth_t, docker_plugin_var_run_t, docker_plugin_var_run_t)
|
||||
manage_lnk_files_pattern(docker_auth_t, docker_plugin_var_run_t, docker_plugin_var_run_t)
|
||||
files_pid_filetrans(docker_auth_t, docker_plugin_var_run_t, { dir file lnk_file sock_file })
|
||||
|
||||
domain_use_interactive_fds(docker_auth_t)
|
||||
|
||||
kernel_read_net_sysctls(docker_auth_t)
|
||||
|
||||
auth_use_nsswitch(docker_auth_t)
|
||||
|
||||
files_read_etc_files(docker_auth_t)
|
||||
|
||||
miscfiles_read_localization(docker_auth_t)
|
||||
|
||||
sysnet_dns_name_resolve(docker_auth_t)
|
||||
|
||||
########################################
|
||||
#
|
||||
# OL7.2 systemd selinux update
|
||||
# systemd_machined local policy
|
||||
#
|
||||
allow systemd_machined_t self:capability { dac_override setgid sys_admin sys_chroot sys_ptrace };
|
||||
allow systemd_machined_t systemd_unit_file_t:service { status start };
|
||||
allow systemd_machined_t self:unix_dgram_socket create_socket_perms;
|
||||
|
||||
manage_dirs_pattern(systemd_machined_t, systemd_machined_var_run_t, systemd_machined_var_run_t)
|
||||
manage_files_pattern(systemd_machined_t, systemd_machined_var_run_t, systemd_machined_var_run_t)
|
||||
manage_lnk_files_pattern(systemd_machined_t, systemd_machined_var_run_t, systemd_machined_var_run_t)
|
||||
init_pid_filetrans(systemd_machined_t, systemd_machined_var_run_t, dir, "machines")
|
||||
|
||||
manage_dirs_pattern(systemd_machined_t, systemd_machined_var_lib_t, systemd_machined_var_lib_t)
|
||||
manage_files_pattern(systemd_machined_t, systemd_machined_var_lib_t, systemd_machined_var_lib_t)
|
||||
manage_lnk_files_pattern(systemd_machined_t, systemd_machined_var_lib_t, systemd_machined_var_lib_t)
|
||||
init_var_lib_filetrans(systemd_machined_t, systemd_machined_var_lib_t, dir, "machines")
|
||||
|
||||
kernel_dgram_send(systemd_machined_t)
|
||||
# This is a bug, but need for now.
|
||||
kernel_read_unlabeled_state(systemd_machined_t)
|
||||
|
||||
init_dbus_chat(systemd_machined_t)
|
||||
init_status(systemd_machined_t)
|
||||
|
||||
userdom_dbus_send_all_users(systemd_machined_t)
|
||||
|
||||
term_use_ptmx(systemd_machined_t)
|
||||
|
||||
optional_policy(`
|
||||
dbus_connect_system_bus(systemd_machined_t)
|
||||
dbus_system_bus_client(systemd_machined_t)
|
||||
')
|
||||
|
||||
optional_policy(`
|
||||
docker_read_share_files(systemd_machined_t)
|
||||
docker_spc_read_state(systemd_machined_t)
|
||||
')
|
||||
|
||||
optional_policy(`
|
||||
virt_dbus_chat(systemd_machined_t)
|
||||
virt_sandbox_read_state(systemd_machined_t)
|
||||
virt_signal_sandbox(systemd_machined_t)
|
||||
virt_stream_connect_sandbox(systemd_machined_t)
|
||||
virt_rw_svirt_dev(systemd_machined_t)
|
||||
virt_getattr_sandbox_filesystem(systemd_machined_t)
|
||||
virt_read_sandbox_files(systemd_machined_t)
|
||||
')
|
||||
|
||||
|
|
@ -42,16 +42,16 @@ const (
|
|||
)
|
||||
|
||||
// ErrNoSwarm is returned on leaving a cluster that was never initialized
|
||||
var ErrNoSwarm = fmt.Errorf("This node is not part of swarm")
|
||||
var ErrNoSwarm = fmt.Errorf("This node is not part of a swarm")
|
||||
|
||||
// ErrSwarmExists is returned on initialize or join request for a cluster that has already been activated
|
||||
var ErrSwarmExists = fmt.Errorf("This node is already part of a swarm cluster. Use \"docker swarm leave\" to leave this cluster and join another one.")
|
||||
var ErrSwarmExists = fmt.Errorf("This node is already part of a swarm. Use \"docker swarm leave\" to leave this swarm and join another one.")
|
||||
|
||||
// ErrPendingSwarmExists is returned on initialize or join request for a cluster that is already processing a similar request but has not succeeded yet.
|
||||
var ErrPendingSwarmExists = fmt.Errorf("This node is processing an existing join request that has not succeeded yet. Use \"docker swarm leave\" to cancel the current request.")
|
||||
|
||||
// ErrSwarmJoinTimeoutReached is returned when cluster join could not complete before timeout was reached.
|
||||
var ErrSwarmJoinTimeoutReached = fmt.Errorf("Timeout was reached before node was joined. Attempt to join the cluster will continue in the background. Use \"docker info\" command to see the current swarm status of your node.")
|
||||
var ErrSwarmJoinTimeoutReached = fmt.Errorf("Timeout was reached before node was joined. The attempt to join the swarm will continue in the background. Use the \"docker info\" command to see the current swarm status of your node.")
|
||||
|
||||
// defaultSpec contains some sane defaults if cluster options are missing on init
|
||||
var defaultSpec = types.Spec{
|
||||
|
@ -519,24 +519,24 @@ func (c *Cluster) Leave(force bool) error {
|
|||
}
|
||||
|
||||
if node.Manager() != nil && !force {
|
||||
msg := "You are attempting to leave cluster on a node that is participating as a manager. "
|
||||
msg := "You are attempting to leave the swarm on a node that is participating as a manager. "
|
||||
if c.isActiveManager() {
|
||||
active, reachable, unreachable, err := c.managerStats()
|
||||
if err == nil {
|
||||
if active && reachable-2 <= unreachable {
|
||||
if reachable == 1 && unreachable == 0 {
|
||||
msg += "Removing the last manager will erase all current state of the cluster. Use `--force` to ignore this message. "
|
||||
msg += "Removing the last manager erases all current state of the swarm. Use `--force` to ignore this message. "
|
||||
c.Unlock()
|
||||
return fmt.Errorf(msg)
|
||||
}
|
||||
msg += fmt.Sprintf("Leaving the cluster will leave you with %v managers out of %v. This means Raft quorum will be lost and your cluster will become inaccessible. ", reachable-1, reachable+unreachable)
|
||||
msg += fmt.Sprintf("Removing this node leaves %v managers out of %v. Without a Raft quorum your swarm will be inaccessible. ", reachable-1, reachable+unreachable)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
msg += "Doing so may lose the consensus of your cluster. "
|
||||
}
|
||||
|
||||
msg += "The only way to restore a cluster that has lost consensus is to reinitialize it with `--force-new-cluster`. Use `--force` to ignore this message."
|
||||
msg += "The only way to restore a swarm that has lost consensus is to reinitialize it with `--force-new-cluster`. Use `--force` to suppress this message."
|
||||
c.Unlock()
|
||||
return fmt.Errorf(msg)
|
||||
}
|
||||
|
@ -1023,7 +1023,7 @@ func (c *Cluster) UpdateNode(nodeID string, version uint64, spec types.NodeSpec)
|
|||
}
|
||||
|
||||
// RemoveNode removes a node from a cluster
|
||||
func (c *Cluster) RemoveNode(input string) error {
|
||||
func (c *Cluster) RemoveNode(input string, force bool) error {
|
||||
c.RLock()
|
||||
defer c.RUnlock()
|
||||
|
||||
|
@ -1039,7 +1039,7 @@ func (c *Cluster) RemoveNode(input string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
if _, err := c.client.RemoveNode(ctx, &swarmapi.RemoveNodeRequest{NodeID: node.ID}); err != nil {
|
||||
if _, err := c.client.RemoveNode(ctx, &swarmapi.RemoveNodeRequest{NodeID: node.ID, Force: force}); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
|
|
@ -53,6 +53,10 @@ func (c *containerConfig) setTask(t *api.Task) error {
|
|||
return ErrImageRequired
|
||||
}
|
||||
|
||||
if err := validateMounts(container.Mounts); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// index the networks by name
|
||||
c.networksAttachments = make(map[string]*api.NetworkAttachment, len(t.Networks))
|
||||
for _, attachment := range t.Networks {
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
executorpkg "github.com/docker/docker/daemon/cluster/executor"
|
||||
"github.com/docker/engine-api/types"
|
||||
"github.com/docker/engine-api/types/events"
|
||||
"github.com/docker/libnetwork"
|
||||
"github.com/docker/swarmkit/agent/exec"
|
||||
"github.com/docker/swarmkit/api"
|
||||
"github.com/docker/swarmkit/log"
|
||||
|
@ -160,8 +161,23 @@ func (r *controller) Start(ctx context.Context) error {
|
|||
return exec.ErrTaskStarted
|
||||
}
|
||||
|
||||
if err := r.adapter.start(ctx); err != nil {
|
||||
return errors.Wrap(err, "starting container failed")
|
||||
for {
|
||||
if err := r.adapter.start(ctx); err != nil {
|
||||
if _, ok := err.(libnetwork.ErrNoSuchNetwork); ok {
|
||||
// Retry network creation again if we
|
||||
// failed because some of the networks
|
||||
// were not found.
|
||||
if err := r.adapter.createNetworks(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
return errors.Wrap(err, "starting container failed")
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
|
||||
// no health check
|
||||
|
|
43
daemon/cluster/executor/container/validate.go
Normal file
43
daemon/cluster/executor/container/validate.go
Normal file
|
@ -0,0 +1,43 @@
|
|||
package container
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/docker/swarmkit/api"
|
||||
)
|
||||
|
||||
func validateMounts(mounts []api.Mount) error {
|
||||
for _, mount := range mounts {
|
||||
// Target must always be absolute
|
||||
if !filepath.IsAbs(mount.Target) {
|
||||
return fmt.Errorf("invalid mount target, must be an absolute path: %s", mount.Target)
|
||||
}
|
||||
|
||||
switch mount.Type {
|
||||
// The checks on abs paths are required due to the container API confusing
|
||||
// volume mounts as bind mounts when the source is absolute (and vice-versa)
|
||||
// See #25253
|
||||
// TODO: This is probably not neccessary once #22373 is merged
|
||||
case api.MountTypeBind:
|
||||
if !filepath.IsAbs(mount.Source) {
|
||||
return fmt.Errorf("invalid bind mount source, must be an absolute path: %s", mount.Source)
|
||||
}
|
||||
if _, err := os.Stat(mount.Source); os.IsNotExist(err) {
|
||||
return fmt.Errorf("invalid bind mount source, source path not found: %s", mount.Source)
|
||||
}
|
||||
case api.MountTypeVolume:
|
||||
if filepath.IsAbs(mount.Source) {
|
||||
return fmt.Errorf("invalid volume mount source, must not be an absolute path: %s", mount.Source)
|
||||
}
|
||||
case api.MountTypeTmpfs:
|
||||
if mount.Source != "" {
|
||||
return fmt.Errorf("invalid tmpfs source, source must be empty")
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("invalid mount type: %s", mount.Type)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
141
daemon/cluster/executor/container/validate_test.go
Normal file
141
daemon/cluster/executor/container/validate_test.go
Normal file
|
@ -0,0 +1,141 @@
|
|||
package container
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/docker/daemon"
|
||||
"github.com/docker/docker/pkg/stringid"
|
||||
"github.com/docker/swarmkit/api"
|
||||
)
|
||||
|
||||
func newTestControllerWithMount(m api.Mount) (*controller, error) {
|
||||
return newController(&daemon.Daemon{}, &api.Task{
|
||||
ID: stringid.GenerateRandomID(),
|
||||
ServiceID: stringid.GenerateRandomID(),
|
||||
Spec: api.TaskSpec{
|
||||
Runtime: &api.TaskSpec_Container{
|
||||
Container: &api.ContainerSpec{
|
||||
Image: "image_name",
|
||||
Labels: map[string]string{
|
||||
"com.docker.swarm.task.id": "id",
|
||||
},
|
||||
Mounts: []api.Mount{m},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestControllerValidateMountBind(t *testing.T) {
|
||||
// with improper source
|
||||
if _, err := newTestControllerWithMount(api.Mount{
|
||||
Type: api.MountTypeBind,
|
||||
Source: "foo",
|
||||
Target: testAbsPath,
|
||||
}); err == nil || !strings.Contains(err.Error(), "invalid bind mount source") {
|
||||
t.Fatalf("expected error, got: %v", err)
|
||||
}
|
||||
|
||||
// with non-existing source
|
||||
if _, err := newTestControllerWithMount(api.Mount{
|
||||
Type: api.MountTypeBind,
|
||||
Source: "/some-non-existing-host-path/",
|
||||
Target: testAbsPath,
|
||||
}); err == nil || !strings.Contains(err.Error(), "invalid bind mount source") {
|
||||
t.Fatalf("expected error, got: %v", err)
|
||||
}
|
||||
|
||||
// with proper source
|
||||
tmpdir, err := ioutil.TempDir("", "TestControllerValidateMountBind")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create temp dir: %v", err)
|
||||
}
|
||||
defer os.Remove(tmpdir)
|
||||
|
||||
if _, err := newTestControllerWithMount(api.Mount{
|
||||
Type: api.MountTypeBind,
|
||||
Source: tmpdir,
|
||||
Target: testAbsPath,
|
||||
}); err != nil {
|
||||
t.Fatalf("expected error, got: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestControllerValidateMountVolume(t *testing.T) {
|
||||
// with improper source
|
||||
if _, err := newTestControllerWithMount(api.Mount{
|
||||
Type: api.MountTypeVolume,
|
||||
Source: testAbsPath,
|
||||
Target: testAbsPath,
|
||||
}); err == nil || !strings.Contains(err.Error(), "invalid volume mount source") {
|
||||
t.Fatalf("expected error, got: %v", err)
|
||||
}
|
||||
|
||||
// with proper source
|
||||
if _, err := newTestControllerWithMount(api.Mount{
|
||||
Type: api.MountTypeVolume,
|
||||
Source: "foo",
|
||||
Target: testAbsPath,
|
||||
}); err != nil {
|
||||
t.Fatalf("expected error, got: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestControllerValidateMountTarget(t *testing.T) {
|
||||
tmpdir, err := ioutil.TempDir("", "TestControllerValidateMountTarget")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create temp dir: %v", err)
|
||||
}
|
||||
defer os.Remove(tmpdir)
|
||||
|
||||
// with improper target
|
||||
if _, err := newTestControllerWithMount(api.Mount{
|
||||
Type: api.MountTypeBind,
|
||||
Source: testAbsPath,
|
||||
Target: "foo",
|
||||
}); err == nil || !strings.Contains(err.Error(), "invalid mount target") {
|
||||
t.Fatalf("expected error, got: %v", err)
|
||||
}
|
||||
|
||||
// with proper target
|
||||
if _, err := newTestControllerWithMount(api.Mount{
|
||||
Type: api.MountTypeBind,
|
||||
Source: tmpdir,
|
||||
Target: testAbsPath,
|
||||
}); err != nil {
|
||||
t.Fatalf("expected no error, got: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestControllerValidateMountTmpfs(t *testing.T) {
|
||||
// with improper target
|
||||
if _, err := newTestControllerWithMount(api.Mount{
|
||||
Type: api.MountTypeTmpfs,
|
||||
Source: "foo",
|
||||
Target: testAbsPath,
|
||||
}); err == nil || !strings.Contains(err.Error(), "invalid tmpfs source") {
|
||||
t.Fatalf("expected error, got: %v", err)
|
||||
}
|
||||
|
||||
// with proper target
|
||||
if _, err := newTestControllerWithMount(api.Mount{
|
||||
Type: api.MountTypeTmpfs,
|
||||
Target: testAbsPath,
|
||||
}); err != nil {
|
||||
t.Fatalf("expected no error, got: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestControllerValidateMountInvalidType(t *testing.T) {
|
||||
// with improper target
|
||||
if _, err := newTestControllerWithMount(api.Mount{
|
||||
Type: api.Mount_MountType(9999),
|
||||
Source: "foo",
|
||||
Target: testAbsPath,
|
||||
}); err == nil || !strings.Contains(err.Error(), "invalid mount type") {
|
||||
t.Fatalf("expected error, got: %v", err)
|
||||
}
|
||||
}
|
7
daemon/cluster/executor/container/validate_unix_test.go
Normal file
7
daemon/cluster/executor/container/validate_unix_test.go
Normal file
|
@ -0,0 +1,7 @@
|
|||
// +build !windows
|
||||
|
||||
package container
|
||||
|
||||
const (
|
||||
testAbsPath = "/foo"
|
||||
)
|
|
@ -0,0 +1,5 @@
|
|||
package container
|
||||
|
||||
const (
|
||||
testAbsPath = `c:\foo`
|
||||
)
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
var (
|
||||
errNoSuchInterface = errors.New("no such interface")
|
||||
errMultipleIPs = errors.New("could not choose an IP address to advertise since this system has multiple addresses")
|
||||
errNoIP = errors.New("could not find the system's IP address")
|
||||
errMustSpecifyListenAddr = errors.New("must specify a listening address because the address to advertise is not recognized as a system address")
|
||||
errBadListenAddr = errors.New("listen address must be an IP address or network interface (with optional port number)")
|
||||
|
@ -159,6 +158,7 @@ func (c *Cluster) resolveSystemAddr() (net.IP, error) {
|
|||
}
|
||||
|
||||
var systemAddr net.IP
|
||||
var systemInterface net.Interface
|
||||
|
||||
// List Docker-managed subnets
|
||||
v4Subnets := c.config.NetworkSubnetsProvider.V4Subnets()
|
||||
|
@ -197,7 +197,7 @@ ifaceLoop:
|
|||
}
|
||||
|
||||
if interfaceAddr4 != nil {
|
||||
return nil, errMultipleIPs
|
||||
return nil, fmt.Errorf("could not choose an IP address to advertise since this system has multiple addresses on interface %s (%s and %s)", intf.Name, interfaceAddr4, ipAddr.IP)
|
||||
}
|
||||
|
||||
interfaceAddr4 = ipAddr.IP
|
||||
|
@ -212,7 +212,7 @@ ifaceLoop:
|
|||
}
|
||||
|
||||
if interfaceAddr6 != nil {
|
||||
return nil, errMultipleIPs
|
||||
return nil, fmt.Errorf("could not choose an IP address to advertise since this system has multiple addresses on interface %s (%s and %s)", intf.Name, interfaceAddr6, ipAddr.IP)
|
||||
}
|
||||
|
||||
interfaceAddr6 = ipAddr.IP
|
||||
|
@ -223,14 +223,16 @@ ifaceLoop:
|
|||
// and exactly one IPv6 address, favor IPv4 over IPv6.
|
||||
if interfaceAddr4 != nil {
|
||||
if systemAddr != nil {
|
||||
return nil, errMultipleIPs
|
||||
return nil, fmt.Errorf("could not choose an IP address to advertise since this system has multiple addresses on different interfaces (%s on %s and %s on %s)", systemAddr, systemInterface.Name, interfaceAddr4, intf.Name)
|
||||
}
|
||||
systemAddr = interfaceAddr4
|
||||
systemInterface = intf
|
||||
} else if interfaceAddr6 != nil {
|
||||
if systemAddr != nil {
|
||||
return nil, errMultipleIPs
|
||||
return nil, fmt.Errorf("could not choose an IP address to advertise since this system has multiple addresses on different interfaces (%s on %s and %s on %s)", systemAddr, systemInterface.Name, interfaceAddr6, intf.Name)
|
||||
}
|
||||
systemAddr = interfaceAddr6
|
||||
systemInterface = intf
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -606,6 +606,10 @@ func NewDaemon(config *Config, registryService registry.Service, containerdRemot
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if err := pluginInit(d, config, containerdRemote); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return d, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
package daemon
|
||||
|
||||
import (
|
||||
"github.com/docker/docker/libcontainerd"
|
||||
"github.com/docker/docker/plugin"
|
||||
"github.com/docker/engine-api/types/container"
|
||||
)
|
||||
|
@ -11,6 +12,15 @@ func (daemon *Daemon) verifyExperimentalContainerSettings(hostConfig *container.
|
|||
return nil, nil
|
||||
}
|
||||
|
||||
func pluginShutdown() {
|
||||
plugin.GetManager().Shutdown()
|
||||
func pluginInit(d *Daemon, cfg *Config, remote libcontainerd.Remote) error {
|
||||
return plugin.Init(cfg.Root, remote, d.RegistryService, cfg.LiveRestore, d.LogPluginEvent)
|
||||
}
|
||||
|
||||
func pluginShutdown() {
|
||||
manager := plugin.GetManager()
|
||||
// Check for a valid manager object. In error conditions, daemon init can fail
|
||||
// and shutdown called, before plugin manager is initialized.
|
||||
if manager != nil {
|
||||
manager.Shutdown()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,11 +2,18 @@
|
|||
|
||||
package daemon
|
||||
|
||||
import "github.com/docker/engine-api/types/container"
|
||||
import (
|
||||
"github.com/docker/docker/libcontainerd"
|
||||
"github.com/docker/engine-api/types/container"
|
||||
)
|
||||
|
||||
func (daemon *Daemon) verifyExperimentalContainerSettings(hostConfig *container.HostConfig, config *container.Config) ([]string, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func pluginInit(d *Daemon, config *Config, remote libcontainerd.Remote) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func pluginShutdown() {
|
||||
}
|
||||
|
|
|
@ -55,6 +55,21 @@ func (daemon *Daemon) LogImageEventWithAttributes(imageID, refName, action strin
|
|||
daemon.EventsService.Log(action, events.ImageEventType, actor)
|
||||
}
|
||||
|
||||
// LogPluginEvent generates an event related to a plugin with only the default attributes.
|
||||
func (daemon *Daemon) LogPluginEvent(pluginID, refName, action string) {
|
||||
daemon.LogPluginEventWithAttributes(pluginID, refName, action, map[string]string{})
|
||||
}
|
||||
|
||||
// LogPluginEventWithAttributes generates an event related to a plugin with specific given attributes.
|
||||
func (daemon *Daemon) LogPluginEventWithAttributes(pluginID, refName, action string, attributes map[string]string) {
|
||||
attributes["name"] = refName
|
||||
actor := events.Actor{
|
||||
ID: pluginID,
|
||||
Attributes: attributes,
|
||||
}
|
||||
daemon.EventsService.Log(action, events.PluginEventType, actor)
|
||||
}
|
||||
|
||||
// LogVolumeEvent generates an event related to a volume.
|
||||
func (daemon *Daemon) LogVolumeEvent(volumeID, action string, attributes map[string]string) {
|
||||
actor := events.Actor{
|
||||
|
|
|
@ -22,6 +22,7 @@ func (ef *Filter) Include(ev events.Message) bool {
|
|||
ef.filter.ExactMatch("type", ev.Type) &&
|
||||
ef.matchDaemon(ev) &&
|
||||
ef.matchContainer(ev) &&
|
||||
ef.matchPlugin(ev) &&
|
||||
ef.matchVolume(ev) &&
|
||||
ef.matchNetwork(ev) &&
|
||||
ef.matchImage(ev) &&
|
||||
|
@ -43,6 +44,10 @@ func (ef *Filter) matchContainer(ev events.Message) bool {
|
|||
return ef.fuzzyMatchName(ev, events.ContainerEventType)
|
||||
}
|
||||
|
||||
func (ef *Filter) matchPlugin(ev events.Message) bool {
|
||||
return ef.fuzzyMatchName(ev, events.PluginEventType)
|
||||
}
|
||||
|
||||
func (ef *Filter) matchVolume(ev events.Message) bool {
|
||||
return ef.fuzzyMatchName(ev, events.VolumeEventType)
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package daemon
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
|
@ -86,6 +87,15 @@ type listContext struct {
|
|||
*types.ContainerListOptions
|
||||
}
|
||||
|
||||
// byContainerCreated is a temporary type used to sort a list of containers by creation time.
|
||||
type byContainerCreated []*container.Container
|
||||
|
||||
func (r byContainerCreated) Len() int { return len(r) }
|
||||
func (r byContainerCreated) Swap(i, j int) { r[i], r[j] = r[j], r[i] }
|
||||
func (r byContainerCreated) Less(i, j int) bool {
|
||||
return r[i].Created.UnixNano() < r[j].Created.UnixNano()
|
||||
}
|
||||
|
||||
// Containers returns the list of containers to show given the user's filtering.
|
||||
func (daemon *Daemon) Containers(config *types.ContainerListOptions) ([]*types.Container, error) {
|
||||
return daemon.reduceContainers(config, daemon.transformContainer)
|
||||
|
@ -149,6 +159,11 @@ func (daemon *Daemon) filterByNameIDMatches(ctx *listContext) []*container.Conta
|
|||
for id := range matches {
|
||||
cntrs = append(cntrs, daemon.containers.Get(id))
|
||||
}
|
||||
|
||||
// Restore sort-order after filtering
|
||||
// Created gives us nanosec resolution for sorting
|
||||
sort.Sort(sort.Reverse(byContainerCreated(cntrs)))
|
||||
|
||||
return cntrs
|
||||
}
|
||||
|
||||
|
|
|
@ -3352,7 +3352,7 @@ Instruct the driver to remove the network (`id`).
|
|||
|
||||
## 3.6 Nodes
|
||||
|
||||
**Note**: Nodes operations require to first be part of a Swarm.
|
||||
**Note**: Node operations require the engine to be part of a swarm.
|
||||
|
||||
### List nodes
|
||||
|
||||
|
@ -3613,12 +3613,12 @@ JSON Parameters:
|
|||
|
||||
## 3.7 Swarm
|
||||
|
||||
### Initialize a new Swarm
|
||||
### Initialize a new swarm
|
||||
|
||||
|
||||
`POST /swarm/init`
|
||||
|
||||
Initialize a new Swarm
|
||||
Initialize a new swarm
|
||||
|
||||
**Example request**:
|
||||
|
||||
|
@ -3647,7 +3647,7 @@ Initialize a new Swarm
|
|||
|
||||
- **200** – no error
|
||||
- **400** – bad parameter
|
||||
- **406** – node is already part of a Swarm
|
||||
- **406** – node is already part of a swarm
|
||||
|
||||
JSON Parameters:
|
||||
|
||||
|
@ -3661,9 +3661,9 @@ JSON Parameters:
|
|||
number, like `eth0:4567`. If the port number is omitted, the port number from the listen
|
||||
address is used. If `AdvertiseAddr` is not specified, it will be automatically detected when
|
||||
possible.
|
||||
- **ForceNewCluster** – Force creating a new Swarm even if already part of one.
|
||||
- **Spec** – Configuration settings of the new Swarm.
|
||||
- **Orchestration** – Configuration settings for the orchestration aspects of the Swarm.
|
||||
- **ForceNewCluster** – Force creation of a new swarm.
|
||||
- **Spec** – Configuration settings for the new swarm.
|
||||
- **Orchestration** – Configuration settings for the orchestration aspects of the swarm.
|
||||
- **TaskHistoryRetentionLimit** – Maximum number of tasks history stored.
|
||||
- **Raft** – Raft related configuration.
|
||||
- **SnapshotInterval** – Number of logs entries between snapshot.
|
||||
|
@ -3685,12 +3685,11 @@ JSON Parameters:
|
|||
- **Options** - An object with key/value pairs that are interpreted
|
||||
as protocol-specific options for the external CA driver.
|
||||
|
||||
### Join an existing Swarm
|
||||
|
||||
### Join an existing swarm
|
||||
|
||||
`POST /swarm/join`
|
||||
|
||||
Join an existing new Swarm
|
||||
Join an existing swarm
|
||||
|
||||
**Example request**:
|
||||
|
||||
|
@ -3714,7 +3713,7 @@ Join an existing new Swarm
|
|||
|
||||
- **200** – no error
|
||||
- **400** – bad parameter
|
||||
- **406** – node is already part of a Swarm
|
||||
- **406** – node is already part of a swarm
|
||||
|
||||
JSON Parameters:
|
||||
|
||||
|
@ -3725,15 +3724,15 @@ JSON Parameters:
|
|||
number, like `eth0:4567`. If the port number is omitted, the port number from the listen
|
||||
address is used. If `AdvertiseAddr` is not specified, it will be automatically detected when
|
||||
possible.
|
||||
- **RemoteAddr** – Address of any manager node already participating in the Swarm to join.
|
||||
- **RemoteAddr** – Address of any manager node already participating in the swarm.
|
||||
- **JoinToken** – Secret token for joining this Swarm.
|
||||
|
||||
### Leave a Swarm
|
||||
### Leave a swarm
|
||||
|
||||
|
||||
`POST /swarm/leave`
|
||||
|
||||
Leave a Swarm
|
||||
Leave a swarm
|
||||
|
||||
**Example request**:
|
||||
|
||||
|
@ -3748,14 +3747,14 @@ Leave a Swarm
|
|||
**Status codes**:
|
||||
|
||||
- **200** – no error
|
||||
- **406** – node is not part of a Swarm
|
||||
- **406** – node is not part of a swarm
|
||||
|
||||
### Update a Swarm
|
||||
### Update a swarm
|
||||
|
||||
|
||||
`POST /swarm/update`
|
||||
|
||||
Update a Swarm
|
||||
Update a swarm
|
||||
|
||||
**Example request**:
|
||||
|
||||
|
@ -3802,11 +3801,11 @@ Update a Swarm
|
|||
|
||||
- **200** – no error
|
||||
- **400** – bad parameter
|
||||
- **406** – node is not part of a Swarm
|
||||
- **406** – node is not part of a swarm
|
||||
|
||||
JSON Parameters:
|
||||
|
||||
- **Orchestration** – Configuration settings for the orchestration aspects of the Swarm.
|
||||
- **Orchestration** – Configuration settings for the orchestration aspects of the swarm.
|
||||
- **TaskHistoryRetentionLimit** – Maximum number of tasks history stored.
|
||||
- **Raft** – Raft related configuration.
|
||||
- **SnapshotInterval** – Number of logs entries between snapshot.
|
||||
|
@ -3827,13 +3826,13 @@ JSON Parameters:
|
|||
- **URL** - URL where certificate signing requests should be sent.
|
||||
- **Options** - An object with key/value pairs that are interpreted
|
||||
as protocol-specific options for the external CA driver.
|
||||
- **JoinTokens** - Tokens that can be used by other nodes to join the Swarm.
|
||||
- **JoinTokens** - Tokens that can be used by other nodes to join the swarm.
|
||||
- **Worker** - Token to use for joining as a worker.
|
||||
- **Manager** - Token to use for joining as a manager.
|
||||
|
||||
## 3.8 Services
|
||||
|
||||
**Note**: Service operations require to first be part of a Swarm.
|
||||
**Note**: Service operations require to first be part of a swarm.
|
||||
|
||||
### List services
|
||||
|
||||
|
@ -4019,7 +4018,7 @@ Create a service
|
|||
**Status codes**:
|
||||
|
||||
- **201** – no error
|
||||
- **406** – server error or node is not part of a Swarm
|
||||
- **406** – server error or node is not part of a swarm
|
||||
- **409** – name conflicts with an existing object
|
||||
|
||||
JSON Parameters:
|
||||
|
@ -4318,7 +4317,7 @@ Update the service `id`.
|
|||
|
||||
## 3.9 Tasks
|
||||
|
||||
**Note**: Tasks operations require to first be part of a Swarm.
|
||||
**Note**: Task operations require the engine to be part of a swarm.
|
||||
|
||||
### List tasks
|
||||
|
||||
|
|
|
@ -30,6 +30,10 @@ Docker images report the following events:
|
|||
|
||||
delete, import, load, pull, push, save, tag, untag
|
||||
|
||||
Docker plugins(experimental) report the following events:
|
||||
|
||||
install, enable, disable, remove
|
||||
|
||||
Docker volumes report the following events:
|
||||
|
||||
create, mount, unmount, destroy
|
||||
|
@ -74,6 +78,7 @@ The currently supported filters are:
|
|||
* container (`container=<name or id>`)
|
||||
* event (`event=<event action>`)
|
||||
* image (`image=<tag or id>`)
|
||||
* plugin (experimental) (`plugin=<name or id>`)
|
||||
* label (`label=<key>` or `label=<key>=<value>`)
|
||||
* type (`type=<container or image or volume or network or daemon>`)
|
||||
* volume (`volume=<name or id>`)
|
||||
|
@ -171,3 +176,7 @@ relative to the current time on the client machine:
|
|||
$ docker events --filter 'type=network'
|
||||
2015-12-23T21:38:24.705709133Z network create 8b111217944ba0ba844a65b13efcd57dc494932ee2527577758f939315ba2c5b (name=test-event-network-local, type=bridge)
|
||||
2015-12-23T21:38:25.119625123Z network connect 8b111217944ba0ba844a65b13efcd57dc494932ee2527577758f939315ba2c5b (name=test-event-network-local, container=b4be644031a3d90b400f88ab3d4bdf4dc23adb250e696b6328b85441abe2c54e, type=bridge)
|
||||
|
||||
$ docker events --filter 'type=plugin' (experimental)
|
||||
2016-07-25T17:30:14.825557616Z plugin pull ec7b87f2ce84330fe076e666f17dfc049d2d7ae0b8190763de94e1f2d105993f (name=tiborvass/no-remove:latest)
|
||||
2016-07-25T17:30:14.888127370Z plugin enable ec7b87f2ce84330fe076e666f17dfc049d2d7ae0b8190763de94e1f2d105993f (name=tiborvass/no-remove:latest)
|
||||
|
|
|
@ -117,7 +117,7 @@ read the [`dockerd`](dockerd.md) reference page.
|
|||
| [node update](node_update.md) | Update attributes for a node |
|
||||
| [node ps](node_ps.md) | List tasks running on a node |
|
||||
| [node ls](node_ls.md) | List nodes in the swarm |
|
||||
| [node rm](node_rm.md) | Remove a node from the swarm |
|
||||
| [node rm](node_rm.md) | Remove one or more nodes from the swarm |
|
||||
|
||||
### Swarm swarm commands
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ available on the volume where `/var/lib/docker` is mounted.
|
|||
## Display Docker system information
|
||||
|
||||
Here is a sample output for a daemon running on Ubuntu, using the overlay
|
||||
storage driver and a node that is part of a 2 node swarm cluster:
|
||||
storage driver and a node that is part of a 2-node swarm:
|
||||
|
||||
$ docker -D info
|
||||
Containers: 14
|
||||
|
|
|
@ -13,7 +13,7 @@ parent = "smn_cli"
|
|||
```markdown
|
||||
Usage: docker kill [OPTIONS] CONTAINER [CONTAINER...]
|
||||
|
||||
Kill one or more running container
|
||||
Kill one or more running containers
|
||||
|
||||
Options:
|
||||
--help Print usage
|
||||
|
|
|
@ -11,9 +11,9 @@ parent = "smn_cli"
|
|||
# network rm
|
||||
|
||||
```markdown
|
||||
Usage: docker network rm NETWORK [NETWORK]...
|
||||
Usage: docker network rm NETWORK [NETWORK...]
|
||||
|
||||
Remove a network
|
||||
Remove one or more networks
|
||||
|
||||
Aliases:
|
||||
rm, remove
|
||||
|
|
|
@ -13,14 +13,14 @@ parent = "smn_cli"
|
|||
```markdown
|
||||
Usage: docker node demote NODE [NODE...]
|
||||
|
||||
Demote a node from manager in the swarm
|
||||
Demote one or more nodes from manager in the swarm
|
||||
|
||||
Options:
|
||||
--help Print usage
|
||||
|
||||
```
|
||||
|
||||
Demotes an existing manager so that it is no longer a manager. This command targets a docker engine that is a manager in the swarm cluster.
|
||||
Demotes an existing manager so that it is no longer a manager. This command targets a docker engine that is a manager in the swarm.
|
||||
|
||||
|
||||
```bash
|
||||
|
|
|
@ -13,13 +13,13 @@ parent = "smn_cli"
|
|||
```markdown
|
||||
Usage: docker node promote NODE [NODE...]
|
||||
|
||||
Promote a node to a manager in the swarm
|
||||
Promote one or more nodes to manager in the swarm
|
||||
|
||||
Options:
|
||||
--help Print usage
|
||||
```
|
||||
|
||||
Promotes a node that is pending a promotion to manager. This command targets a docker engine that is a manager in the swarm cluster.
|
||||
Promotes a node to manager. This command targets a docker engine that is a manager in the swarm.
|
||||
|
||||
|
||||
```bash
|
||||
|
|
|
@ -13,14 +13,15 @@ parent = "smn_cli"
|
|||
# node rm
|
||||
|
||||
```markdown
|
||||
Usage: docker node rm NODE [NODE...]
|
||||
Usage: docker node rm [OPTIONS] NODE [NODE...]
|
||||
|
||||
Remove a node from the swarm
|
||||
Remove one or more nodes from the swarm
|
||||
|
||||
Aliases:
|
||||
rm, remove
|
||||
|
||||
Options:
|
||||
--force Force remove an active node
|
||||
--help Print usage
|
||||
```
|
||||
|
||||
|
@ -32,6 +33,24 @@ Example output:
|
|||
$ docker node rm swarm-node-02
|
||||
Node swarm-node-02 removed from swarm
|
||||
|
||||
Removes nodes from the swarm that are in the down state. Attempting to remove
|
||||
an active node will result in an error:
|
||||
|
||||
```bash
|
||||
$ docker node rm swarm-node-03
|
||||
Error response from daemon: rpc error: code = 9 desc = node swarm-node-03 is not down and can't be removed
|
||||
```
|
||||
|
||||
If a worker node becomes compromised, exhibits unexpected or unwanted behavior, or if you lose access to it so
|
||||
that a clean shutdown is impossible, you can use the force option.
|
||||
|
||||
```bash
|
||||
$ docker node rm --force swarm-node-03
|
||||
Node swarm-node-03 removed from swarm
|
||||
```
|
||||
|
||||
Note that manager nodes have to be demoted to worker nodes before they can be removed
|
||||
from the cluster.
|
||||
|
||||
## Related information
|
||||
|
||||
|
|
|
@ -13,9 +13,9 @@ parent = "smn_cli"
|
|||
# service rm
|
||||
|
||||
```Markdown
|
||||
Usage: docker service rm [OPTIONS] SERVICE
|
||||
Usage: docker service rm [OPTIONS] SERVICE [SERVICE...]
|
||||
|
||||
Remove a service
|
||||
Remove one or more services
|
||||
|
||||
Aliases:
|
||||
rm, remove
|
||||
|
|
|
@ -28,8 +28,8 @@ Options:
|
|||
--task-history-limit int Task history retention limit (default 5)
|
||||
```
|
||||
|
||||
Initialize a swarm cluster. The docker engine targeted by this command becomes a manager
|
||||
in the newly created one node swarm cluster.
|
||||
Initialize a swarm. The docker engine targeted by this command becomes a manager
|
||||
in the newly created single-node swarm.
|
||||
|
||||
|
||||
```bash
|
||||
|
@ -37,14 +37,12 @@ $ docker swarm init --advertise-addr 192.168.99.121
|
|||
Swarm initialized: current node (bvz81updecsj6wjz393c09vti) is now a manager.
|
||||
|
||||
To add a worker to this swarm, run the following command:
|
||||
|
||||
docker swarm join \
|
||||
--token SWMTKN-1-3pu6hszjas19xyp7ghgosyx9k8atbfcr8p2is99znpy26u2lkl-1awxwuwd3z9j1z3puu7rcgdbx \
|
||||
172.17.0.2:2377
|
||||
|
||||
To add a manager to this swarm, run the following command:
|
||||
docker swarm join \
|
||||
--token SWMTKN-1-3pu6hszjas19xyp7ghgosyx9k8atbfcr8p2is99znpy26u2lkl-7p73s1dx5in4tatdymyhg9hu2 \
|
||||
172.17.0.2:2377
|
||||
To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
|
||||
```
|
||||
|
||||
`docker swarm init` generates two random tokens, a worker token and a manager token. When you join
|
||||
|
|
|
@ -36,12 +36,14 @@ the swarm:
|
|||
```bash
|
||||
$ docker swarm join-token worker
|
||||
To add a worker to this swarm, run the following command:
|
||||
|
||||
docker swarm join \
|
||||
--token SWMTKN-1-3pu6hszjas19xyp7ghgosyx9k8atbfcr8p2is99znpy26u2lkl-1awxwuwd3z9j1z3puu7rcgdbx \
|
||||
172.17.0.2:2377
|
||||
|
||||
$ docker swarm join-token manager
|
||||
To add a manager to this swarm, run the following command:
|
||||
|
||||
docker swarm join \
|
||||
--token SWMTKN-1-3pu6hszjas19xyp7ghgosyx9k8atbfcr8p2is99znpy26u2lkl-7p73s1dx5in4tatdymyhg9hu2 \
|
||||
172.17.0.2:2377
|
||||
|
@ -51,7 +53,10 @@ Use the `--rotate` flag to generate a new join token for the specified role:
|
|||
|
||||
```bash
|
||||
$ docker swarm join-token --rotate worker
|
||||
Succesfully rotated worker join token.
|
||||
|
||||
To add a worker to this swarm, run the following command:
|
||||
|
||||
docker swarm join \
|
||||
--token SWMTKN-1-3pu6hszjas19xyp7ghgosyx9k8atbfcr8p2is99znpy26u2lkl-b30ljddcqhef9b9v4rs7mel7t \
|
||||
172.17.0.2:2377
|
||||
|
@ -63,6 +68,7 @@ The `-q` (or `--quiet`) flag only prints the token:
|
|||
|
||||
```bash
|
||||
$ docker swarm join-token -q worker
|
||||
|
||||
SWMTKN-1-3pu6hszjas19xyp7ghgosyx9k8atbfcr8p2is99znpy26u2lkl-b30ljddcqhef9b9v4rs7mel7t
|
||||
```
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ Options:
|
|||
--task-history-limit int Task history retention limit (default 5)
|
||||
```
|
||||
|
||||
Updates a swarm cluster with new parameter values. This command must target a manager node.
|
||||
Updates a swarm with new parameter values. This command must target a manager node.
|
||||
|
||||
|
||||
```bash
|
||||
|
|
|
@ -11,9 +11,9 @@ parent = "smn_cli"
|
|||
# volume rm
|
||||
|
||||
```markdown
|
||||
Usage: docker volume rm VOLUME [VOLUME]...
|
||||
Usage: docker volume rm VOLUME [VOLUME...]
|
||||
|
||||
Remove a volume
|
||||
Remove one or more volumes
|
||||
|
||||
Aliases:
|
||||
rm, remove
|
||||
|
@ -22,7 +22,7 @@ Options:
|
|||
--help Print usage
|
||||
```
|
||||
|
||||
Removes one or more volumes. You cannot remove a volume that is in use by a container.
|
||||
Remove one or more volumes. You cannot remove a volume that is in use by a container.
|
||||
|
||||
$ docker volume rm hello
|
||||
hello
|
||||
|
|
|
@ -17,7 +17,7 @@ repository](https://github.com/docker/docker/releases). Alternatively, install
|
|||
the latest Docker for Mac or Docker for Windows Beta.
|
||||
|
||||
Docker Engine 1.12 includes swarm mode for natively managing a cluster of
|
||||
Docker Engines called a Swarm. Use the Docker CLI to create a swarm, deploy
|
||||
Docker Engines called a *swarm*. Use the Docker CLI to create a swarm, deploy
|
||||
application services to a swarm, and manage swarm behavior.
|
||||
|
||||
|
||||
|
@ -27,9 +27,9 @@ Swarm](https://docs.docker.com/swarm).
|
|||
## Feature highlights
|
||||
|
||||
* **Cluster management integrated with Docker Engine:** Use the Docker Engine
|
||||
CLI to create a Swarm of Docker Engines where you can deploy application
|
||||
CLI to create a swarm of Docker Engines where you can deploy application
|
||||
services. You don't need additional orchestration software to create or manage
|
||||
a Swarm.
|
||||
a swarm.
|
||||
|
||||
* **Decentralized design:** Instead of handling differentiation between node
|
||||
roles at deployment time, the Docker Engine handles any specialization at
|
||||
|
|
|
@ -43,6 +43,7 @@ following command on a manager node:
|
|||
$ docker swarm join-token worker
|
||||
|
||||
To add a worker to this swarm, run the following command:
|
||||
|
||||
docker swarm join \
|
||||
--token SWMTKN-1-49nj1cmql0jkz5s954yi3oex3nedyz0fb0xx14ie39trti4wxv-8vxv8rssmk743ojnwacrr2e7c \
|
||||
192.168.99.100:2377
|
||||
|
@ -80,7 +81,7 @@ availability. Because swarm mode manager nodes share data using Raft, there
|
|||
must be an odd number of managers. The swarm can continue to function after as
|
||||
long as a quorum of more than half of the manager nodes are available.
|
||||
|
||||
For more detail about swarm managers and administering a swarm cluster, see
|
||||
For more detail about swarm managers and administering a swarm, see
|
||||
[Administer and maintain a swarm of Docker Engines](admin_guide.md).
|
||||
|
||||
To retrieve the join command including the join token for manager nodes, run the
|
||||
|
@ -90,6 +91,7 @@ following command on a manager node:
|
|||
$ docker swarm join-token manager
|
||||
|
||||
To add a manager to this swarm, run the following command:
|
||||
|
||||
docker swarm join \
|
||||
--token SWMTKN-1-61ztec5kyafptydic6jfc1i33t37flcl4nuipzcusor96k7kby-5vy9t8u35tuqm7vh67lrz9xp6 \
|
||||
192.168.99.100:2377
|
||||
|
|
|
@ -77,7 +77,7 @@ PublishedPort for the service in the 30000-32767 range.
|
|||
|
||||
External components, such as cloud load balancers, can access the service on the
|
||||
PublishedPort of any node in the cluster whether or not the node is currently
|
||||
running the task for the service. All nodes in the swarm cluster route ingress
|
||||
running the task for the service. All nodes in the swarm route ingress
|
||||
connections to a running task instance.
|
||||
|
||||
Swarm mode has an internal DNS component that automatically assigns each service
|
||||
|
|
|
@ -56,21 +56,19 @@ swarm.
|
|||
external to the swarm.
|
||||
|
||||
The output for `docker swarm init` provides the connection command to use when
|
||||
you join new worker or manager nodes to the swarm:
|
||||
you join new worker nodes to the swarm:
|
||||
|
||||
```bash
|
||||
$ docker swarm init
|
||||
Swarm initialized: current node (dxn1zf6l61qsb1josjja83ngz) is now a manager.
|
||||
|
||||
To add a worker to this swarm, run the following command:
|
||||
|
||||
docker swarm join \
|
||||
--token SWMTKN-1-49nj1cmql0jkz5s954yi3oex3nedyz0fb0xx14ie39trti4wxv-8vxv8rssmk743ojnwacrr2e7c \
|
||||
192.168.99.100:2377
|
||||
|
||||
To add a manager to this swarm, run the following command:
|
||||
docker swarm join \
|
||||
--token SWMTKN-1-61ztec5kyafptydic6jfc1i33t37flcl4nuipzcusor96k7kby-5vy9t8u35tuqm7vh67lrz9xp6 \
|
||||
192.168.99.100:2377
|
||||
To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
|
||||
```
|
||||
|
||||
### Configure the advertise address
|
||||
|
@ -115,6 +113,7 @@ To retrieve the join command including the join token for worker nodes, run:
|
|||
$ docker swarm join-token worker
|
||||
|
||||
To add a worker to this swarm, run the following command:
|
||||
|
||||
docker swarm join \
|
||||
--token SWMTKN-1-49nj1cmql0jkz5s954yi3oex3nedyz0fb0xx14ie39trti4wxv-8vxv8rssmk743ojnwacrr2e7c \
|
||||
192.168.99.100:2377
|
||||
|
@ -128,6 +127,7 @@ To view the join command and token for manager nodes, run:
|
|||
$ docker swarm join-token manager
|
||||
|
||||
To add a worker to this swarm, run the following command:
|
||||
|
||||
docker swarm join \
|
||||
--token SWMTKN-1-49nj1cmql0jkz5s954yi3oex3nedyz0fb0xx14ie39trti4wxv-8vxv8rssmk743ojnwacrr2e7c \
|
||||
192.168.99.100:2377
|
||||
|
@ -167,6 +167,7 @@ nodes:
|
|||
$docker swarm join-token --rotate worker
|
||||
|
||||
To add a worker to this swarm, run the following command:
|
||||
|
||||
docker swarm join \
|
||||
--token SWMTKN-1-2kscvs0zuymrsc9t0ocyy1rdns9dhaodvpl639j2bqx55uptag-ebmn5u927reawo27s3azntd44 \
|
||||
172.17.0.2:2377
|
||||
|
|
|
@ -36,6 +36,7 @@ This tutorial uses the name `worker1`.
|
|||
$ docker swarm join-token worker
|
||||
|
||||
To add a worker to this swarm, run the following command:
|
||||
|
||||
docker swarm join \
|
||||
--token SWMTKN-1-49nj1cmql0jkz5s954yi3oex3nedyz0fb0xx14ie39trti4wxv-8vxv8rssmk743ojnwacrr2e7c \
|
||||
192.168.99.100:2377
|
||||
|
|
|
@ -33,14 +33,12 @@ node. For example, the tutorial uses a machine named `manager1`.
|
|||
Swarm initialized: current node (dxn1zf6l61qsb1josjja83ngz) is now a manager.
|
||||
|
||||
To add a worker to this swarm, run the following command:
|
||||
|
||||
docker swarm join \
|
||||
--token SWMTKN-1-49nj1cmql0jkz5s954yi3oex3nedyz0fb0xx14ie39trti4wxv-8vxv8rssmk743ojnwacrr2e7c \
|
||||
192.168.99.100:2377
|
||||
|
||||
To add a manager to this swarm, run the following command:
|
||||
docker swarm join \
|
||||
--token SWMTKN-1-61ztec5kyafptydic6jfc1i33t37flcl4nuipzcusor96k7kby-5vy9t8u35tuqm7vh67lrz9xp6 \
|
||||
192.168.99.100:2377
|
||||
To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
|
||||
```
|
||||
|
||||
The `--advertise-addr` flag configures the manager node to publish its
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<!--[metadata]>
|
||||
+++
|
||||
title = "Drain a node"
|
||||
description = "Drain nodes on the Swarm"
|
||||
description = "Drain nodes on the swarm"
|
||||
keywords = ["tutorial, cluster management, swarm, service, drain"]
|
||||
[menu.main]
|
||||
identifier="swarm-tutorial-drain-node"
|
||||
|
@ -45,7 +45,7 @@ update](rolling-update.md) tutorial, start it now:
|
|||
c5uo6kdmzpon37mgj9mwglcfw
|
||||
```
|
||||
|
||||
4. Run `docker service ps redis` to see how the Swarm manager assigned the
|
||||
4. Run `docker service ps redis` to see how the swarm manager assigned the
|
||||
tasks to different nodes:
|
||||
|
||||
```bash
|
||||
|
@ -84,7 +84,7 @@ had a task assigned to it:
|
|||
|
||||
The drained node shows `Drain` for `AVAILABILITY`.
|
||||
|
||||
7. Run `docker service ps redis` to see how the Swarm manager updated the
|
||||
7. Run `docker service ps redis` to see how the swarm manager updated the
|
||||
task assignments for the `redis` service:
|
||||
|
||||
```bash
|
||||
|
|
|
@ -103,7 +103,7 @@ service:
|
|||
|
||||
In this case, the one instance of the `helloworld` service is running on the
|
||||
`worker2` node. You may see the service running on your manager node. By
|
||||
default, manager nodes in a Swarm can execute tasks just like worker nodes.
|
||||
default, manager nodes in a swarm can execute tasks just like worker nodes.
|
||||
|
||||
Swarm also shows you the `DESIRED STATE` and `LAST STATE` of the service
|
||||
task so you can see if tasks are running according to the service
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<!--[metadata]>
|
||||
+++
|
||||
title = "Apply rolling updates"
|
||||
description = "Apply rolling updates to a service on the Swarm"
|
||||
description = "Apply rolling updates to a service on the swarm"
|
||||
keywords = ["tutorial, cluster management, swarm, service, rolling-update"]
|
||||
[menu.main]
|
||||
identifier="swarm-tutorial-rolling-update"
|
||||
|
@ -151,4 +151,4 @@ desired state:
|
|||
`redis:3.0.6` while others are running `redis:3.0.7`. The output above shows
|
||||
the state once the rolling updates are done.
|
||||
|
||||
Next, learn about how to [drain a node](drain-node.md) in the Swarm.
|
||||
Next, learn about how to [drain a node](drain-node.md) in the swarm.
|
||||
|
|
|
@ -462,7 +462,7 @@ Docker Engine for use with `overlay` network. There are three options to set:
|
|||
</tbody>
|
||||
</table>
|
||||
|
||||
Create an `overlay` network on one of the machines in the Swarm.
|
||||
Create an `overlay` network on one of the machines in the swarm.
|
||||
|
||||
$ docker network create --driver overlay my-multi-host-network
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ check_forked() {
|
|||
Upstream release is '$lsb_dist' version '$dist_version'.
|
||||
EOF
|
||||
else
|
||||
if [ -r /etc/debian_version ] && [ "$lsb_dist" != "ubuntu" ]; then
|
||||
if [ -r /etc/debian_version ] && [ "$lsb_dist" != "ubuntu" ] && [ "$lsb_dist" != "raspbian" ]; then
|
||||
# We're Debian and don't even know it!
|
||||
lsb_dist=debian
|
||||
dist_version="$(cat /etc/debian_version | sed 's/\/.*//' | sed 's/\..*//')"
|
||||
|
@ -129,10 +129,12 @@ do_install() {
|
|||
case "$(uname -m)" in
|
||||
*64)
|
||||
;;
|
||||
armv6l|armv7l)
|
||||
;;
|
||||
*)
|
||||
cat >&2 <<-'EOF'
|
||||
Error: you are not using a 64bit platform.
|
||||
Docker currently only supports 64bit platforms.
|
||||
Error: you are not using a 64bit platform or a Raspberry Pi (armv6l/armv7l).
|
||||
Docker currently only supports 64bit platforms or a Raspberry Pi (armv6l/armv7l).
|
||||
EOF
|
||||
exit 1
|
||||
;;
|
||||
|
@ -268,7 +270,7 @@ do_install() {
|
|||
fi
|
||||
;;
|
||||
|
||||
debian)
|
||||
debian|raspbian)
|
||||
dist_version="$(cat /etc/debian_version | sed 's/\/.*//' | sed 's/\..*//')"
|
||||
case "$dist_version" in
|
||||
8)
|
||||
|
@ -375,7 +377,7 @@ do_install() {
|
|||
exit 0
|
||||
;;
|
||||
|
||||
ubuntu|debian)
|
||||
ubuntu|debian|raspbian)
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
did_apt_get_update=
|
||||
|
@ -386,24 +388,31 @@ do_install() {
|
|||
fi
|
||||
}
|
||||
|
||||
# aufs is preferred over devicemapper; try to ensure the driver is available.
|
||||
if ! grep -q aufs /proc/filesystems && ! $sh_c 'modprobe aufs'; then
|
||||
if uname -r | grep -q -- '-generic' && dpkg -l 'linux-image-*-generic' | grep -qE '^ii|^hi' 2>/dev/null; then
|
||||
kern_extras="linux-image-extra-$(uname -r) linux-image-extra-virtual"
|
||||
if [ "$lsb_dist" = "raspbian" ]; then
|
||||
# Create Raspbian specific systemd unit file, use overlay by default
|
||||
( set -x; $sh_c "mkdir -p /etc/systemd/system" )
|
||||
( set -x; $sh_c "$curl https://raw.githubusercontent.com/docker/docker/master/contrib/init/systemd/docker.service > /etc/systemd/system/docker.service" )
|
||||
( set -x; $sh_c "sed -i 's/dockerd/dockerd --storage-driver overlay/' /etc/systemd/system/docker.service" )
|
||||
else
|
||||
# aufs is preferred over devicemapper; try to ensure the driver is available.
|
||||
if ! grep -q aufs /proc/filesystems && ! $sh_c 'modprobe aufs'; then
|
||||
if uname -r | grep -q -- '-generic' && dpkg -l 'linux-image-*-generic' | grep -qE '^ii|^hi' 2>/dev/null; then
|
||||
kern_extras="linux-image-extra-$(uname -r) linux-image-extra-virtual"
|
||||
|
||||
apt_get_update
|
||||
( set -x; $sh_c 'sleep 3; apt-get install -y -q '"$kern_extras" ) || true
|
||||
apt_get_update
|
||||
( set -x; $sh_c 'sleep 3; apt-get install -y -q '"$kern_extras" ) || true
|
||||
|
||||
if ! grep -q aufs /proc/filesystems && ! $sh_c 'modprobe aufs'; then
|
||||
echo >&2 'Warning: tried to install '"$kern_extras"' (for AUFS)'
|
||||
echo >&2 ' but we still have no AUFS. Docker may not work. Proceeding anyways!'
|
||||
if ! grep -q aufs /proc/filesystems && ! $sh_c 'modprobe aufs'; then
|
||||
echo >&2 'Warning: tried to install '"$kern_extras"' (for AUFS)'
|
||||
echo >&2 ' but we still have no AUFS. Docker may not work. Proceeding anyways!'
|
||||
( set -x; sleep 10 )
|
||||
fi
|
||||
else
|
||||
echo >&2 'Warning: current kernel is not supported by the linux-image-extra-virtual'
|
||||
echo >&2 ' package. We have no AUFS support. Consider installing the packages'
|
||||
echo >&2 ' linux-image-virtual kernel and linux-image-extra-virtual for AUFS support.'
|
||||
( set -x; sleep 10 )
|
||||
fi
|
||||
else
|
||||
echo >&2 'Warning: current kernel is not supported by the linux-image-extra-virtual'
|
||||
echo >&2 ' package. We have no AUFS support. Consider installing the packages'
|
||||
echo >&2 ' linux-image-virtual kernel and linux-image-extra-virtual for AUFS support.'
|
||||
( set -x; sleep 10 )
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
|
@ -135,8 +135,12 @@ set -e
|
|||
# selinux policy referencing systemd things won't work on non-systemd versions
|
||||
# of centos or rhel, which we don't support anyways
|
||||
if [ "${suite%.*}" -gt 6 ] && [[ "$version" != opensuse* ]]; then
|
||||
selinuxDir="selinux"
|
||||
if [ -d "./contrib/selinux-$version" ]; then
|
||||
selinuxDir="selinux-${version}"
|
||||
fi
|
||||
cat >> "$DEST/$version/Dockerfile.build" <<-EOF
|
||||
RUN tar -cz -C /usr/src/${rpmName}/contrib -f /root/rpmbuild/SOURCES/${rpmName}-selinux.tar.gz ${rpmName}-selinux
|
||||
RUN tar -cz -C /usr/src/${rpmName}/contrib/${selinuxDir} -f /root/rpmbuild/SOURCES/${rpmName}-selinux.tar.gz ${rpmName}-selinux
|
||||
RUN rpmbuild -ba \
|
||||
--define '_gitcommit $DOCKER_GITCOMMIT' \
|
||||
--define '_release $rpmRelease' \
|
||||
|
|
|
@ -14,9 +14,6 @@ set -e
|
|||
#
|
||||
# ... and so on and so forth for the builds created by hack/make/build-deb
|
||||
|
||||
source "$(dirname "$BASH_SOURCE")/.integration-daemon-start"
|
||||
source "$(dirname "$BASH_SOURCE")/.detect-daemon-osarch"
|
||||
|
||||
: ${DOCKER_RELEASE_DIR:=$DEST}
|
||||
: ${GPG_KEYID:=releasedocker}
|
||||
APTDIR=$DOCKER_RELEASE_DIR/apt/repo
|
||||
|
@ -25,7 +22,7 @@ APTDIR=$DOCKER_RELEASE_DIR/apt/repo
|
|||
mkdir -p "$APTDIR/conf" "$APTDIR/db" "$APTDIR/dists"
|
||||
|
||||
# supported arches/sections
|
||||
arches=( amd64 i386 )
|
||||
arches=( amd64 i386 armhf )
|
||||
|
||||
# Preserve existing components but don't add any non-existing ones
|
||||
for component in main testing experimental ; do
|
||||
|
@ -77,7 +74,7 @@ TreeDefault {
|
|||
};
|
||||
EOF
|
||||
|
||||
for dir in contrib/builder/deb/${PACKAGE_ARCH}/*/; do
|
||||
for dir in bundles/$VERSION/build-deb/*/; do
|
||||
version="$(basename "$dir")"
|
||||
suite="${version//debootstrap-}"
|
||||
|
||||
|
@ -98,12 +95,12 @@ APT::FTPArchive::Release::Architectures "${arches[*]}";
|
|||
EOF
|
||||
|
||||
# release the debs
|
||||
for dir in contrib/builder/deb/${PACKAGE_ARCH}/*/; do
|
||||
for dir in bundles/$VERSION/build-deb/*/; do
|
||||
version="$(basename "$dir")"
|
||||
codename="${version//debootstrap-}"
|
||||
|
||||
tempdir="$(mktemp -d /tmp/tmp-docker-release-deb.XXXXXXXX)"
|
||||
DEBFILE=( "bundles/$VERSION/build-deb/$version/docker-engine"*.deb )
|
||||
DEBFILE=( "$dir/docker-engine"*.deb )
|
||||
|
||||
# add the deb for each component for the distro version into the
|
||||
# pool (if it is not there already)
|
||||
|
@ -128,7 +125,9 @@ for dir in contrib/builder/deb/${PACKAGE_ARCH}/*/; do
|
|||
|
||||
# build the right directory structure, needed for apt-ftparchive
|
||||
for arch in "${arches[@]}"; do
|
||||
mkdir -p "$APTDIR/dists/$codename/$component/binary-$arch"
|
||||
for c in "${components[@]}"; do
|
||||
mkdir -p "$APTDIR/dists/$codename/$c/binary-$arch"
|
||||
done
|
||||
done
|
||||
|
||||
# update the filelist for this codename/component
|
||||
|
@ -139,7 +138,7 @@ done
|
|||
# run the apt-ftparchive commands so we can have pinning
|
||||
apt-ftparchive generate "$APTDIR/conf/apt-ftparchive.conf"
|
||||
|
||||
for dir in contrib/builder/deb/${PACKAGE_ARCH}/*/; do
|
||||
for dir in bundles/$VERSION/build-deb/*/; do
|
||||
version="$(basename "$dir")"
|
||||
codename="${version//debootstrap-}"
|
||||
|
||||
|
|
|
@ -14,16 +14,10 @@ set -e
|
|||
#
|
||||
# ... and so on and so forth for the builds created by hack/make/build-rpm
|
||||
|
||||
source "$(dirname "$BASH_SOURCE")/.integration-daemon-start"
|
||||
source "$(dirname "$BASH_SOURCE")/.detect-daemon-osarch"
|
||||
|
||||
: ${DOCKER_RELEASE_DIR:=$DEST}
|
||||
YUMDIR=$DOCKER_RELEASE_DIR/yum/repo
|
||||
: ${GPG_KEYID:=releasedocker}
|
||||
|
||||
# manage the repos for each distribution separately
|
||||
distros=( fedora centos opensuse oraclelinux )
|
||||
|
||||
# get the release
|
||||
release="main"
|
||||
|
||||
|
@ -35,44 +29,42 @@ if [ $DOCKER_EXPERIMENTAL ] || [[ "$VERSION" == *-dev ]] || [ -n "$(git status -
|
|||
release="experimental"
|
||||
fi
|
||||
|
||||
for distro in "${distros[@]}"; do
|
||||
# Setup the yum repo
|
||||
REPO=$YUMDIR/$release/$distro
|
||||
# Setup the yum repo
|
||||
for dir in bundles/$VERSION/build-rpm/*/; do
|
||||
version="$(basename "$dir")"
|
||||
suite="${version##*-}"
|
||||
|
||||
for dir in contrib/builder/rpm/${PACKAGE_ARCH}/$distro-*/; do
|
||||
version="$(basename "$dir")"
|
||||
suite="${version##*-}"
|
||||
REPO=$YUMDIR/$release/$suite
|
||||
|
||||
# if the directory does not exist, initialize the yum repo
|
||||
if [[ ! -d $REPO/$suite/Packages ]]; then
|
||||
mkdir -p "$REPO/$suite/Packages"
|
||||
# if the directory does not exist, initialize the yum repo
|
||||
if [[ ! -d $REPO/$suite/Packages ]]; then
|
||||
mkdir -p "$REPO/$suite/Packages"
|
||||
|
||||
createrepo --pretty "$REPO/$suite"
|
||||
fi
|
||||
createrepo --pretty "$REPO/$suite"
|
||||
fi
|
||||
|
||||
# path to rpms
|
||||
RPMFILE=( "bundles/$VERSION/build-rpm/$version/RPMS/"*"/docker-engine"*.rpm "bundles/$VERSION/build-rpm/$version/SRPMS/docker-engine"*.rpm )
|
||||
# path to rpms
|
||||
RPMFILE=( "bundles/$VERSION/build-rpm/$version/RPMS/"*"/docker-engine"*.rpm "bundles/$VERSION/build-rpm/$version/SRPMS/docker-engine"*.rpm )
|
||||
|
||||
# if we have a $GPG_PASSPHRASE we may as well
|
||||
# sign the rpms before adding to repo
|
||||
if [ ! -z $GPG_PASSPHRASE ]; then
|
||||
# export our key to rpm import
|
||||
gpg --armor --export "$GPG_KEYID" > /tmp/gpg
|
||||
rpm --import /tmp/gpg
|
||||
# if we have a $GPG_PASSPHRASE we may as well
|
||||
# sign the rpms before adding to repo
|
||||
if [ ! -z $GPG_PASSPHRASE ]; then
|
||||
# export our key to rpm import
|
||||
gpg --armor --export "$GPG_KEYID" > /tmp/gpg
|
||||
rpm --import /tmp/gpg
|
||||
|
||||
# sign the rpms
|
||||
echo "yes" | setsid rpm \
|
||||
--define "_gpg_name $GPG_KEYID" \
|
||||
--define "_signature gpg" \
|
||||
--define "__gpg_check_password_cmd /bin/true" \
|
||||
--define "__gpg_sign_cmd %{__gpg} gpg --batch --no-armor --passphrase '$GPG_PASSPHRASE' --no-secmem-warning -u '%{_gpg_name}' --sign --detach-sign --output %{__signature_filename} %{__plaintext_filename}" \
|
||||
--resign "${RPMFILE[@]}"
|
||||
fi
|
||||
# sign the rpms
|
||||
echo "yes" | setsid rpm \
|
||||
--define "_gpg_name $GPG_KEYID" \
|
||||
--define "_signature gpg" \
|
||||
--define "__gpg_check_password_cmd /bin/true" \
|
||||
--define "__gpg_sign_cmd %{__gpg} gpg --batch --no-armor --passphrase '$GPG_PASSPHRASE' --no-secmem-warning -u '%{_gpg_name}' --sign --detach-sign --output %{__signature_filename} %{__plaintext_filename}" \
|
||||
--resign "${RPMFILE[@]}"
|
||||
fi
|
||||
|
||||
# copy the rpms to the packages folder
|
||||
cp "${RPMFILE[@]}" "$REPO/$suite/Packages"
|
||||
# copy the rpms to the packages folder
|
||||
cp "${RPMFILE[@]}" "$REPO/$suite/Packages"
|
||||
|
||||
# update the repo
|
||||
createrepo --pretty --update "$REPO/$suite"
|
||||
done
|
||||
# update the repo
|
||||
createrepo --pretty --update "$REPO/$suite"
|
||||
done
|
||||
|
|
|
@ -60,12 +60,12 @@ clone git golang.org/x/net 2beffdc2e92c8a3027590f898fe88f69af48a3f8 https://gith
|
|||
clone git golang.org/x/sys eb2c74142fd19a79b3f237334c7384d5167b1b46 https://github.com/golang/sys.git
|
||||
clone git github.com/docker/go-units 651fc226e7441360384da338d0fd37f2440ffbe3
|
||||
clone git github.com/docker/go-connections fa2850ff103453a9ad190da0df0af134f0314b3d
|
||||
clone git github.com/docker/engine-api 3d1601b9d2436a70b0dfc045a23f6503d19195df
|
||||
clone git github.com/docker/engine-api 4eca04ae18f4f93f40196a17b9aa6e11262a7269
|
||||
clone git github.com/RackSec/srslog 259aed10dfa74ea2961eddd1d9847619f6e98837
|
||||
clone git github.com/imdario/mergo 0.2.1
|
||||
|
||||
#get libnetwork packages
|
||||
clone git github.com/docker/libnetwork 5e7bf83ab07c197d1bef6ec073d9f19ce59e3eb2
|
||||
clone git github.com/docker/libnetwork 24f64a6f9e9cade70e3904df291fb321584b1b4e
|
||||
clone git github.com/docker/go-events afb2b9f2c23f33ada1a22b03651775fdc65a5089
|
||||
clone git github.com/armon/go-radix e39d623f12e8e41c7b5529e9a9dd67a1e2261f80
|
||||
clone git github.com/armon/go-metrics eb0af217e5e9747e41dd5303755356b62d28e3ec
|
||||
|
@ -139,7 +139,7 @@ clone git github.com/docker/docker-credential-helpers v0.3.0
|
|||
clone git github.com/docker/containerd 0ac3cd1be170d180b2baed755e8f0da547ceb267
|
||||
|
||||
# cluster
|
||||
clone git github.com/docker/swarmkit 9d4c2f73124e70f8fa85f9076635b827d17b109f
|
||||
clone git github.com/docker/swarmkit 3708fb309aacfff321759bcdcc99b0f57806d27f
|
||||
clone git github.com/golang/mock bd3c8e81be01eef76d4b503f5e687d2d1354d2d9
|
||||
clone git github.com/gogo/protobuf 43a2e0b1c32252bfbbdf81f7faa7a88fb3fa4028
|
||||
clone git github.com/cloudflare/cfssl b895b0549c0ff676f92cf09ba971ae02bb41367b
|
||||
|
|
|
@ -208,6 +208,17 @@ func (d *SwarmDaemon) getNode(c *check.C, id string) *swarm.Node {
|
|||
return &node
|
||||
}
|
||||
|
||||
func (d *SwarmDaemon) removeNode(c *check.C, id string, force bool) {
|
||||
url := "/nodes/" + id
|
||||
if force {
|
||||
url += "?force=1"
|
||||
}
|
||||
|
||||
status, out, err := d.SockRequest("DELETE", url, nil)
|
||||
c.Assert(status, checker.Equals, http.StatusOK, check.Commentf("output: %q", string(out)))
|
||||
c.Assert(err, checker.IsNil)
|
||||
}
|
||||
|
||||
func (d *SwarmDaemon) updateNode(c *check.C, id string, f ...nodeConstructor) {
|
||||
for i := 0; ; i++ {
|
||||
node := d.getNode(c, id)
|
||||
|
|
|
@ -510,6 +510,37 @@ func (s *DockerSwarmSuite) TestApiSwarmNodeUpdate(c *check.C) {
|
|||
c.Assert(n.Spec.Availability, checker.Equals, swarm.NodeAvailabilityPause)
|
||||
}
|
||||
|
||||
func (s *DockerSwarmSuite) TestApiSwarmNodeRemove(c *check.C) {
|
||||
testRequires(c, Network)
|
||||
d1 := s.AddDaemon(c, true, true)
|
||||
d2 := s.AddDaemon(c, true, false)
|
||||
_ = s.AddDaemon(c, true, false)
|
||||
|
||||
nodes := d1.listNodes(c)
|
||||
c.Assert(len(nodes), checker.Equals, 3, check.Commentf("nodes: %#v", nodes))
|
||||
|
||||
// Getting the info so we can take the NodeID
|
||||
d2Info, err := d2.info()
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
// forceful removal of d2 should work
|
||||
d1.removeNode(c, d2Info.NodeID, true)
|
||||
|
||||
nodes = d1.listNodes(c)
|
||||
c.Assert(len(nodes), checker.Equals, 2, check.Commentf("nodes: %#v", nodes))
|
||||
|
||||
// Restart the node that was removed
|
||||
err = d2.Restart()
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
// Give some time for the node to rejoin
|
||||
time.Sleep(1 * time.Second)
|
||||
|
||||
// Make sure the node didn't rejoin
|
||||
nodes = d1.listNodes(c)
|
||||
c.Assert(len(nodes), checker.Equals, 2, check.Commentf("nodes: %#v", nodes))
|
||||
}
|
||||
|
||||
func (s *DockerSwarmSuite) TestApiSwarmNodeDrainPause(c *check.C) {
|
||||
testRequires(c, Network)
|
||||
d1 := s.AddDaemon(c, true, true)
|
||||
|
@ -708,9 +739,14 @@ func (s *DockerSwarmSuite) TestApiSwarmForceNewCluster(c *check.C) {
|
|||
id := d1.createService(c, simpleTestService, setInstances(instances))
|
||||
waitAndAssert(c, defaultReconciliationTimeout, reducedCheck(sumAsIntegers, d1.checkActiveContainerCount, d2.checkActiveContainerCount), checker.Equals, instances)
|
||||
|
||||
c.Assert(d2.Stop(), checker.IsNil)
|
||||
// drain d2, all containers should move to d1
|
||||
d1.updateNode(c, d2.NodeID, func(n *swarm.Node) {
|
||||
n.Spec.Availability = swarm.NodeAvailabilityDrain
|
||||
})
|
||||
waitAndAssert(c, defaultReconciliationTimeout, d1.checkActiveContainerCount, checker.Equals, instances)
|
||||
waitAndAssert(c, defaultReconciliationTimeout, d2.checkActiveContainerCount, checker.Equals, 0)
|
||||
|
||||
time.Sleep(5 * time.Second)
|
||||
c.Assert(d2.Stop(), checker.IsNil)
|
||||
|
||||
c.Assert(d1.Init(swarm.InitRequest{
|
||||
ForceNewCluster: true,
|
||||
|
|
|
@ -46,7 +46,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithPluginEnabled(c *check.C) {
|
|||
c.Assert(out, checker.Contains, "true")
|
||||
}
|
||||
|
||||
// TestDaemonRestartWithPluginEnabled tests state restore for a disabled plugin
|
||||
// TestDaemonRestartWithPluginDisabled tests state restore for a disabled plugin
|
||||
func (s *DockerDaemonSuite) TestDaemonRestartWithPluginDisabled(c *check.C) {
|
||||
if err := s.d.Start(); err != nil {
|
||||
c.Fatalf("Could not start daemon: %v", err)
|
||||
|
|
|
@ -297,6 +297,32 @@ func (s *DockerSuite) TestEventsImageLoad(c *check.C) {
|
|||
c.Assert(matches["action"], checker.Equals, "save", check.Commentf("matches: %v\nout:\n%s\n", matches, out))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestEventsPluginOps(c *check.C) {
|
||||
testRequires(c, DaemonIsLinux, ExperimentalDaemon)
|
||||
|
||||
pluginName := "tiborvass/no-remove:latest"
|
||||
since := daemonUnixTime(c)
|
||||
|
||||
dockerCmd(c, "plugin", "install", pluginName, "--grant-all-permissions")
|
||||
dockerCmd(c, "plugin", "disable", pluginName)
|
||||
dockerCmd(c, "plugin", "remove", pluginName)
|
||||
|
||||
out, _ := dockerCmd(c, "events", "--since", since, "--until", daemonUnixTime(c))
|
||||
events := strings.Split(out, "\n")
|
||||
events = events[:len(events)-1]
|
||||
|
||||
nEvents := len(events)
|
||||
c.Assert(nEvents, checker.GreaterOrEqualThan, 4)
|
||||
|
||||
pluginEvents := eventActionsByIDAndType(c, events, pluginName, "plugin")
|
||||
c.Assert(pluginEvents, checker.HasLen, 4, check.Commentf("events: %v", events))
|
||||
|
||||
c.Assert(pluginEvents[0], checker.Equals, "pull", check.Commentf(out))
|
||||
c.Assert(pluginEvents[1], checker.Equals, "enable", check.Commentf(out))
|
||||
c.Assert(pluginEvents[2], checker.Equals, "disable", check.Commentf(out))
|
||||
c.Assert(pluginEvents[3], checker.Equals, "remove", check.Commentf(out))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestEventsFilters(c *check.C) {
|
||||
since := daemonUnixTime(c)
|
||||
dockerCmd(c, "run", "--rm", "busybox", "true")
|
||||
|
|
|
@ -239,7 +239,9 @@ func (s *DockerSuite) TestInspectBindMountPoint(c *check.C) {
|
|||
c.Assert(m.Driver, checker.Equals, "")
|
||||
c.Assert(m.Source, checker.Equals, prefix+slash+"data")
|
||||
c.Assert(m.Destination, checker.Equals, prefix+slash+"data")
|
||||
c.Assert(m.Mode, checker.Equals, "ro"+modifier)
|
||||
if daemonPlatform != "windows" { // Windows does not set mode
|
||||
c.Assert(m.Mode, checker.Equals, "ro"+modifier)
|
||||
}
|
||||
c.Assert(m.RW, checker.Equals, false)
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,10 @@ import (
|
|||
"github.com/docker/docker/pkg/integration/checker"
|
||||
"github.com/go-check/check"
|
||||
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
@ -26,7 +30,16 @@ func (s *DockerSuite) TestPluginBasicOps(c *check.C) {
|
|||
|
||||
out, _, err = dockerCmdWithError("plugin", "inspect", pNameWithTag)
|
||||
c.Assert(err, checker.IsNil)
|
||||
c.Assert(out, checker.Contains, "A test plugin for Docker")
|
||||
tmpFile, err := ioutil.TempFile("", "inspect.json")
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer tmpFile.Close()
|
||||
|
||||
if _, err := tmpFile.Write([]byte(out)); err != nil {
|
||||
c.Fatal(err)
|
||||
}
|
||||
// FIXME: When `docker plugin inspect` takes a format as input, jq can be replaced.
|
||||
id, err := exec.Command("jq", ".Id", "--raw-output", tmpFile.Name()).CombinedOutput()
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
out, _, err = dockerCmdWithError("plugin", "remove", pNameWithTag)
|
||||
c.Assert(out, checker.Contains, "is active")
|
||||
|
@ -37,6 +50,11 @@ func (s *DockerSuite) TestPluginBasicOps(c *check.C) {
|
|||
out, _, err = dockerCmdWithError("plugin", "remove", pNameWithTag)
|
||||
c.Assert(err, checker.IsNil)
|
||||
c.Assert(out, checker.Contains, pNameWithTag)
|
||||
|
||||
_, err = os.Stat(filepath.Join(dockerBasePath, "plugins", string(id)))
|
||||
if !os.IsNotExist(err) {
|
||||
c.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestPluginInstallDisable(c *check.C) {
|
||||
|
@ -68,3 +86,24 @@ func (s *DockerSuite) TestPluginInstallImage(c *check.C) {
|
|||
c.Assert(err, checker.NotNil)
|
||||
c.Assert(out, checker.Contains, "content is not a plugin")
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestPluginEnableDisableNegative(c *check.C) {
|
||||
testRequires(c, DaemonIsLinux, ExperimentalDaemon)
|
||||
out, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", pName)
|
||||
c.Assert(err, checker.IsNil)
|
||||
c.Assert(strings.TrimSpace(out), checker.Contains, pName)
|
||||
|
||||
out, _, err = dockerCmdWithError("plugin", "enable", pName)
|
||||
c.Assert(err, checker.NotNil)
|
||||
c.Assert(strings.TrimSpace(out), checker.Contains, "already enabled")
|
||||
|
||||
_, _, err = dockerCmdWithError("plugin", "disable", pName)
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
out, _, err = dockerCmdWithError("plugin", "disable", pName)
|
||||
c.Assert(err, checker.NotNil)
|
||||
c.Assert(strings.TrimSpace(out), checker.Contains, "already disabled")
|
||||
|
||||
_, _, err = dockerCmdWithError("plugin", "remove", pName)
|
||||
c.Assert(err, checker.IsNil)
|
||||
}
|
||||
|
|
|
@ -864,3 +864,37 @@ func (s *DockerSuite) TestPsListContainersFilterNetwork(c *check.C) {
|
|||
|
||||
c.Assert(containerOut, checker.Contains, "onbridgenetwork")
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestPsByOrder(c *check.C) {
|
||||
name1 := "xyz-abc"
|
||||
out, err := runSleepingContainer(c, "--name", name1)
|
||||
c.Assert(err, checker.NotNil)
|
||||
c.Assert(strings.TrimSpace(out), checker.Not(checker.Equals), "")
|
||||
container1 := strings.TrimSpace(out)
|
||||
|
||||
name2 := "xyz-123"
|
||||
out, err = runSleepingContainer(c, "--name", name2)
|
||||
c.Assert(err, checker.NotNil)
|
||||
c.Assert(strings.TrimSpace(out), checker.Not(checker.Equals), "")
|
||||
container2 := strings.TrimSpace(out)
|
||||
|
||||
name3 := "789-abc"
|
||||
out, err = runSleepingContainer(c, "--name", name3)
|
||||
c.Assert(err, checker.NotNil)
|
||||
c.Assert(strings.TrimSpace(out), checker.Not(checker.Equals), "")
|
||||
|
||||
name4 := "789-123"
|
||||
out, err = runSleepingContainer(c, "--name", name4)
|
||||
c.Assert(err, checker.NotNil)
|
||||
c.Assert(strings.TrimSpace(out), checker.Not(checker.Equals), "")
|
||||
|
||||
// Run multiple time should have the same result
|
||||
out, err = dockerCmd(c, "ps", "--no-trunc", "-q", "-f", "name=xyz")
|
||||
c.Assert(err, checker.NotNil)
|
||||
c.Assert(strings.TrimSpace(out), checker.Equals, fmt.Sprintf("%s\n%s", container2, container1))
|
||||
|
||||
// Run multiple time should have the same result
|
||||
out, err = dockerCmd(c, "ps", "--no-trunc", "-q", "-f", "name=xyz")
|
||||
c.Assert(err, checker.NotNil)
|
||||
c.Assert(strings.TrimSpace(out), checker.Equals, fmt.Sprintf("%s\n%s", container2, container1))
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue