Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
7a87de5
daemon: remove graphdb usage
LK4D4 Aug 16, 2016
50c26ad
Remove sqlite
justincormack Jan 17, 2017
df43aea
Remove sqlite part II
kolyshkin Apr 30, 2020
aae588c
remove Register return value
Feb 6, 2017
336fc39
Use counter for tracking container states
cpuguy83 Feb 10, 2017
0d7b3a6
Fix some data races
cpuguy83 Feb 1, 2017
a2ea0d9
Don’t hold container lock for size calculation
tonistiigi Feb 19, 2017
3e8d7cc
Lock container while connecting to a new network.
cpuguy83 May 31, 2017
728e96f
fix some typos from module contrib to man
xulike666 Feb 16, 2017
a1ba9c5
Fix issue backporting mount spec to pre-1.13 obj
cpuguy83 Apr 25, 2017
4fe5c48
Add continue on error in mountspec backport
cpuguy83 May 15, 2017
2d1a13c
Grab a lock to read container.RemovalInProgress
fabiokung Feb 21, 2017
930bd51
Move platform specific mount data to Container
fabiokung Feb 22, 2017
7bbd912
in-memory ACID store for containers
fabiokung Feb 22, 2017
a54e2ef
keep a consistent view of containers rendered
fabiokung Feb 22, 2017
d4087f4
stop grabbing container locks during ps
fabiokung Feb 22, 2017
e711203
Move checkpointing to the Container object
fabiokung Feb 23, 2017
1cacebc
how to maintain the container snapshot struct
fabiokung Mar 20, 2017
d5b22a4
no need to save state to disk here
fabiokung Mar 27, 2017
deb82b6
verifyVolumesInfo needs a container lock
fabiokung Mar 27, 2017
5f181a8
no need to save container state here
fabiokung Mar 27, 2017
1bd5861
save deep copies of Container in the replica store
fabiokung Mar 27, 2017
fcc0ccc
only Daemon.load needs to call label.ReserveLabel
fabiokung Apr 6, 2017
0294ece
avoid re-reading json files when copying containers
fabiokung Apr 6, 2017
1d15055
ensure heath monitor status updates are propagated
fabiokung Apr 6, 2017
7c08422
delete unused code (daemon.Start)
fabiokung Apr 10, 2017
43ebf2e
avoid saving container state to disk before daemon.Register
fabiokung Apr 10, 2017
6e5a2b9
Net operations already hold locks to containers
fabiokung Jun 22, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion 1 Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ RUN apt-get update && apt-get install -y \
libnl-3-dev \
libprotobuf-c0-dev \
libprotobuf-dev \
libsqlite3-dev \
libsystemd-journal-dev \
libtool \
mercurial \
Expand Down
1 change: 0 additions & 1 deletion 1 Dockerfile.aarch64
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ RUN apt-get update && apt-get install -y \
libc6-dev \
libcap-dev \
libltdl-dev \
libsqlite3-dev \
libsystemd-dev \
mercurial \
net-tools \
Expand Down
1 change: 0 additions & 1 deletion 1 Dockerfile.armhf
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ RUN apt-get update && apt-get install -y \
libapparmor-dev \
libcap-dev \
libltdl-dev \
libsqlite3-dev \
libsystemd-journal-dev \
libtool \
mercurial \
Expand Down
1 change: 0 additions & 1 deletion 1 Dockerfile.ppc64le
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ RUN apt-get update && apt-get install -y \
libapparmor-dev \
libcap-dev \
libltdl-dev \
libsqlite3-dev \
libsystemd-journal-dev \
libtool \
mercurial \
Expand Down
1 change: 0 additions & 1 deletion 1 Dockerfile.s390x
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ RUN apt-get update && apt-get install -y \
libapparmor-dev \
libcap-dev \
libltdl-dev \
libsqlite3-dev \
libsystemd-journal-dev \
libtool \
mercurial \
Expand Down
2 changes: 0 additions & 2 deletions 2 Dockerfile.simple
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
git \
libapparmor-dev \
libdevmapper-dev \
libsqlite3-dev \
\
ca-certificates \
e2fsprogs \
iptables \
Expand Down
27 changes: 27 additions & 0 deletions 27 api/types/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ type EndpointIPAMConfig struct {
LinkLocalIPs []string `json:",omitempty"`
}

// Copy makes a copy of the endpoint ipam config
func (cfg *EndpointIPAMConfig) Copy() *EndpointIPAMConfig {
cfgCopy := *cfg
cfgCopy.LinkLocalIPs = make([]string, 0, len(cfg.LinkLocalIPs))
cfgCopy.LinkLocalIPs = append(cfgCopy.LinkLocalIPs, cfg.LinkLocalIPs...)
return &cfgCopy
}

// PeerInfo represents one peer of a overlay network
type PeerInfo struct {
Name string
Expand All @@ -52,6 +60,25 @@ type EndpointSettings struct {
MacAddress string
}

// Copy makes a deep copy of `EndpointSettings`
func (es *EndpointSettings) Copy() *EndpointSettings {
epCopy := *es
if es.IPAMConfig != nil {
epCopy.IPAMConfig = es.IPAMConfig.Copy()
}

if es.Links != nil {
links := make([]string, 0, len(es.Links))
epCopy.Links = append(links, es.Links...)
}

if es.Aliases != nil {
aliases := make([]string, 0, len(es.Aliases))
epCopy.Aliases = append(aliases, es.Aliases...)
}
return &epCopy
}

// NetworkingConfig represents the container's networking configuration for each of its interfaces
// Carries the networking configs specified in the `docker run` and `docker network connect` commands
type NetworkingConfig struct {
Expand Down
1 change: 0 additions & 1 deletion 1 builder/dockerfile/parser/testfiles/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -yq \
iptables \
libapparmor-dev \
libcap-dev \
libsqlite3-dev \
mercurial \
pandoc \
parallel \
Expand Down
2 changes: 1 addition & 1 deletion 2 builder/dockerfile/parser/testfiles/docker/result
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(from "ubuntu:14.04")
(maintainer "Tianon Gravi <admwiggin@gmail.com> (@tianon)")
(run "apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -yq \tapt-utils \taufs-tools \tautomake \tbtrfs-tools \tbuild-essential \tcurl \tdpkg-sig \tgit \tiptables \tlibapparmor-dev \tlibcap-dev \tlibsqlite3-dev \tmercurial \tpandoc \tparallel \treprepro \truby1.9.1 \truby1.9.1-dev \ts3cmd=1.1.0* \t--no-install-recommends")
(run "apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -yq \tapt-utils \taufs-tools \tautomake \tbtrfs-tools \tbuild-essential \tcurl \tdpkg-sig \tgit \tiptables \tlibapparmor-dev \tlibcap-dev \tmercurial \tpandoc \tparallel \treprepro \truby1.9.1 \truby1.9.1-dev \ts3cmd=1.1.0* \t--no-install-recommends")
(run "git clone --no-checkout https://git.fedorahosted.org/git/lvm2.git /usr/local/lvm2 && cd /usr/local/lvm2 && git checkout -q v2_02_103")
(run "cd /usr/local/lvm2 && ./configure --enable-static_link && make device-mapper && make install_device-mapper")
(run "curl -sSL https://golang.org/dl/go1.3.src.tar.gz | tar -v -C /usr/local -xz")
Expand Down
79 changes: 51 additions & 28 deletions 79 container/container.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package container

import (
"bytes"
"encoding/json"
"fmt"
"io"
Expand All @@ -13,8 +14,6 @@ import (
"syscall"
"time"

"golang.org/x/net/context"

"github.com/Sirupsen/logrus"
containertypes "github.com/docker/docker/api/types/container"
mounttypes "github.com/docker/docker/api/types/mount"
Expand Down Expand Up @@ -43,7 +42,7 @@ import (
"github.com/docker/libnetwork/options"
"github.com/docker/libnetwork/types"
agentexec "github.com/docker/swarmkit/agent/exec"
"github.com/opencontainers/runc/libcontainer/label"
"golang.org/x/net/context"
)

const configFileName = "config.v2.json"
Expand Down Expand Up @@ -132,41 +131,51 @@ func (container *Container) FromDisk() error {
return err
}

if err := label.ReserveLabel(container.ProcessLabel); err != nil {
return err
}
return container.readHostConfig()
}

// ToDisk saves the container configuration on disk.
func (container *Container) ToDisk() error {
// toDisk saves the container configuration on disk and returns a deep copy.
func (container *Container) toDisk() (*Container, error) {
var (
buf bytes.Buffer
deepCopy Container
)
pth, err := container.ConfigPath()
if err != nil {
return err
return nil, err
}

jsonSource, err := ioutils.NewAtomicFileWriter(pth, 0644)
// Save container settings
f, err := ioutils.NewAtomicFileWriter(pth, 0644)
if err != nil {
return err
return nil, err
}
defer jsonSource.Close()
defer f.Close()

enc := json.NewEncoder(jsonSource)
w := io.MultiWriter(&buf, f)
if err := json.NewEncoder(w).Encode(container); err != nil {
return nil, err
}

// Save container settings
if err := enc.Encode(container); err != nil {
return err
if err := json.NewDecoder(&buf).Decode(&deepCopy); err != nil {
return nil, err
}
deepCopy.HostConfig, err = container.WriteHostConfig()
if err != nil {
return nil, err
}

return container.WriteHostConfig()
return &deepCopy, nil
}

// ToDiskLocking saves the container configuration on disk in a thread safe way.
func (container *Container) ToDiskLocking() error {
container.Lock()
err := container.ToDisk()
container.Unlock()
return err
// CheckpointTo makes the Container's current state visible to queries, and persists state.
// Callers must hold a Container lock.
func (container *Container) CheckpointTo(store ViewDB) error {
deepCopy, err := container.toDisk()
if err != nil {
return err
}
return store.Save(deepCopy)
}

// readHostConfig reads the host configuration from disk for the container.
Expand Down Expand Up @@ -198,20 +207,34 @@ func (container *Container) readHostConfig() error {
return nil
}

// WriteHostConfig saves the host configuration on disk for the container.
func (container *Container) WriteHostConfig() error {
// WriteHostConfig saves the host configuration on disk for the container,
// and returns a deep copy of the saved object. Callers must hold a Container lock.
func (container *Container) WriteHostConfig() (*containertypes.HostConfig, error) {
var (
buf bytes.Buffer
deepCopy containertypes.HostConfig
)

pth, err := container.HostConfigPath()
if err != nil {
return err
return nil, err
}

f, err := ioutils.NewAtomicFileWriter(pth, 0644)
if err != nil {
return err
return nil, err
}
defer f.Close()

return json.NewEncoder(f).Encode(&container.HostConfig)
w := io.MultiWriter(&buf, f)
if err := json.NewEncoder(w).Encode(&container.HostConfig); err != nil {
return nil, err
}

if err := json.NewDecoder(&buf).Decode(&deepCopy); err != nil {
return nil, err
}
return &deepCopy, nil
}

// SetupWorkingDirectory sets up the container's working directory as set in container.Config.WorkingDir
Expand Down
29 changes: 20 additions & 9 deletions 29 container/container_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"strings"

"github.com/Sirupsen/logrus"
"github.com/docker/docker/api/types"
containertypes "github.com/docker/docker/api/types/container"
mounttypes "github.com/docker/docker/api/types/mount"
"github.com/docker/docker/pkg/chrootarchive"
Expand Down Expand Up @@ -282,11 +283,8 @@ func (container *Container) UnmountSecrets() error {
return detachMounted(container.SecretMountPath())
}

// UpdateContainer updates configuration of a container.
// UpdateContainer updates configuration of a container. Callers must hold a Lock on the Container.
func (container *Container) UpdateContainer(hostConfig *containertypes.HostConfig) error {
container.Lock()
defer container.Unlock()

// update resources of container
resources := hostConfig.Resources
cResources := &container.HostConfig.Resources
Expand Down Expand Up @@ -340,11 +338,6 @@ func (container *Container) UpdateContainer(hostConfig *containertypes.HostConfi
container.HostConfig.RestartPolicy = hostConfig.RestartPolicy
}

if err := container.ToDisk(); err != nil {
logrus.Errorf("Error saving updated container: %v", err)
return err
}

return nil
}

Expand Down Expand Up @@ -492,3 +485,21 @@ func (container *Container) SecretMountRHEL(rootUID, rootGID int) (*Mount, error
m.Writable = true
return m, nil
}

// GetMountPoints gives a platform specific transformation to types.MountPoint. Callers must hold a Container lock.
func (container *Container) GetMountPoints() []types.MountPoint {
mountPoints := make([]types.MountPoint, 0, len(container.MountPoints))
for _, m := range container.MountPoints {
mountPoints = append(mountPoints, types.MountPoint{
Type: m.Type,
Name: m.Name,
Source: m.Path(),
Destination: m.Destination,
Driver: m.Driver,
Mode: m.Mode,
RW: m.RW,
Propagation: m.Propagation,
})
}
return mountPoints
}
21 changes: 18 additions & 3 deletions 21 container/container_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"os"
"path/filepath"

"github.com/docker/docker/api/types"
containertypes "github.com/docker/docker/api/types/container"
"github.com/docker/docker/utils"
)
Expand Down Expand Up @@ -66,10 +67,8 @@ func (container *Container) TmpfsMounts() ([]Mount, error) {
return mounts, nil
}

// UpdateContainer updates configuration of a container
// UpdateContainer updates configuration of a container. Callers must hold a Lock on the Container.
func (container *Container) UpdateContainer(hostConfig *containertypes.HostConfig) error {
container.Lock()
defer container.Unlock()
resources := hostConfig.Resources
if resources.BlkioWeight != 0 || resources.CPUShares != 0 ||
resources.CPUPeriod != 0 || resources.CPUQuota != 0 ||
Expand Down Expand Up @@ -114,3 +113,19 @@ func (container *Container) BuildHostnameFile() error {
func (container *Container) EnableServiceDiscoveryOnDefaultNetwork() bool {
return true
}

// GetMountPoints gives a platform specific transformation to types.MountPoint. Callers must hold a Container lock.
func (container *Container) GetMountPoints() []types.MountPoint {
mountPoints := make([]types.MountPoint, 0, len(container.MountPoints))
for _, m := range container.MountPoints {
mountPoints = append(mountPoints, types.MountPoint{
Type: m.Type,
Name: m.Name,
Source: m.Path(),
Destination: m.Destination,
Driver: m.Driver,
RW: m.RW,
})
}
return mountPoints
}
7 changes: 4 additions & 3 deletions 7 container/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ type Health struct {

// String returns a human-readable description of the health-check state
func (s *Health) String() string {
// This happens when the container is being shutdown and the monitor has stopped
// or the monitor has yet to be setup.
if s.stop == nil {
// This happens when the monitor has yet to be setup.
if s.Status == "" {
return types.Unhealthy
}

Expand Down Expand Up @@ -44,6 +43,8 @@ func (s *Health) CloseMonitorChannel() {
logrus.Debug("CloseMonitorChannel: waiting for probe to stop")
close(s.stop)
s.stop = nil
// unhealthy when the monitor has stopped for compatibility reasons
s.Status = types.Unhealthy
logrus.Debug("CloseMonitorChannel done")
}
}
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.