Skip to content

Commit 9c4570a

Browse files
committed
Replace execdrivers with containerd implementation
Signed-off-by: Tonis Tiigi <[email protected]> Signed-off-by: Kenfe-Mickael Laventure <[email protected]> Signed-off-by: Anusha Ragunathan <[email protected]>
1 parent cc83031 commit 9c4570a

File tree

89 files changed

+5692
-1248
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+5692
-1248
lines changed

Dockerfile

+18
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,24 @@ RUN set -x \
249249
&& go build -v -o /usr/local/bin/rsrc github.com/akavel/rsrc \
250250
&& rm -rf "$GOPATH"
251251

252+
# Install runc
253+
ENV RUNC_COMMIT bbde9c426ff363d813b8722f0744115c13b408b6
254+
RUN set -x \
255+
&& export GOPATH="$(mktemp -d)" \
256+
&& git clone git://github.com/opencontainers/runc.git "$GOPATH/src/github.com/opencontainers/runc" \
257+
&& cd "$GOPATH/src/github.com/opencontainers/runc" \
258+
&& git checkout -q "$RUNC_COMMIT" \
259+
&& make BUILDTAGS="seccomp apparmor selinux" && make install
260+
261+
# Install containerd
262+
ENV CONTAINERD_COMMIT 7146b01a3d7aaa146414cdfb0a6c96cfba5d9091
263+
RUN set -x \
264+
&& export GOPATH="$(mktemp -d)" \
265+
&& git clone git://github.com/docker/containerd.git "$GOPATH/src/github.com/docker/containerd" \
266+
&& cd "$GOPATH/src/github.com/docker/containerd" \
267+
&& git checkout -q "$CONTAINERD_COMMIT" \
268+
&& make && make install
269+
252270
# Wrap all commands in the "docker-in-docker" script to allow nested containers
253271
ENTRYPOINT ["hack/dind"]
254272

Dockerfile.aarch64

+18
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,24 @@ RUN set -x \
186186
&& go build -v -o /usr/local/bin/tomlv github.com/BurntSushi/toml/cmd/tomlv \
187187
&& rm -rf "$GOPATH"
188188

189+
# Install runc
190+
ENV RUNC_COMMIT bbde9c426ff363d813b8722f0744115c13b408b6
191+
RUN set -x \
192+
&& export GOPATH="$(mktemp -d)" \
193+
&& git clone git://github.com/opencontainers/runc.git "$GOPATH/src/github.com/opencontainers/runc" \
194+
&& cd "$GOPATH/src/github.com/opencontainers/runc" \
195+
&& git checkout -q "$RUNC_COMMIT" \
196+
&& make BUILDTAGS="seccomp apparmor selinux" && make install
197+
198+
# Install containerd
199+
ENV CONTAINERD_COMMIT 7146b01a3d7aaa146414cdfb0a6c96cfba5d9091
200+
RUN set -x \
201+
&& export GOPATH="$(mktemp -d)" \
202+
&& git clone git://github.com/docker/containerd.git "$GOPATH/src/github.com/docker/containerd" \
203+
&& cd "$GOPATH/src/github.com/docker/containerd" \
204+
&& git checkout -q "$CONTAINERD_COMMIT" \
205+
&& make && make install
206+
189207
# Wrap all commands in the "docker-in-docker" script to allow nested containers
190208
ENTRYPOINT ["hack/dind"]
191209

Dockerfile.armhf

+18
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,24 @@ RUN set -x \
205205
&& go build -v -o /usr/local/bin/rsrc github.com/akavel/rsrc \
206206
&& rm -rf "$GOPATH"
207207

208+
# Install runc
209+
ENV RUNC_COMMIT bbde9c426ff363d813b8722f0744115c13b408b6
210+
RUN set -x \
211+
&& export GOPATH="$(mktemp -d)" \
212+
&& git clone git://github.com/opencontainers/runc.git "$GOPATH/src/github.com/opencontainers/runc" \
213+
&& cd "$GOPATH/src/github.com/opencontainers/runc" \
214+
&& git checkout -q "$RUNC_COMMIT" \
215+
&& make BUILDTAGS="seccomp apparmor selinux" && make install
216+
217+
# Install containerd
218+
ENV CONTAINERD_COMMIT 7146b01a3d7aaa146414cdfb0a6c96cfba5d9091
219+
RUN set -x \
220+
&& export GOPATH="$(mktemp -d)" \
221+
&& git clone git://github.com/docker/containerd.git "$GOPATH/src/github.com/docker/containerd" \
222+
&& cd "$GOPATH/src/github.com/docker/containerd" \
223+
&& git checkout -q "$CONTAINERD_COMMIT" \
224+
&& make && make install
225+
208226
# Wrap all commands in the "docker-in-docker" script to allow nested containers
209227
ENTRYPOINT ["hack/dind"]
210228

Dockerfile.gccgo

+18
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,24 @@ VOLUME /var/lib/docker
7373
WORKDIR /go/src/github.com/docker/docker
7474
ENV DOCKER_BUILDTAGS apparmor seccomp selinux
7575

76+
# Install runc
77+
ENV RUNC_COMMIT bbde9c426ff363d813b8722f0744115c13b408b6
78+
RUN set -x \
79+
&& export GOPATH="$(mktemp -d)" \
80+
&& git clone git://github.com/opencontainers/runc.git "$GOPATH/src/github.com/opencontainers/runc" \
81+
&& cd "$GOPATH/src/github.com/opencontainers/runc" \
82+
&& git checkout -q "$RUNC_COMMIT" \
83+
&& make BUILDTAGS="seccomp apparmor selinux" && make install
84+
85+
# Install containerd
86+
ENV CONTAINERD_COMMIT 7146b01a3d7aaa146414cdfb0a6c96cfba5d9091
87+
RUN set -x \
88+
&& export GOPATH="$(mktemp -d)" \
89+
&& git clone git://github.com/docker/containerd.git "$GOPATH/src/github.com/docker/containerd" \
90+
&& cd "$GOPATH/src/github.com/docker/containerd" \
91+
&& git checkout -q "$CONTAINERD_COMMIT" \
92+
&& make && make install
93+
7694
# Wrap all commands in the "docker-in-docker" script to allow nested containers
7795
ENTRYPOINT ["hack/dind"]
7896

Dockerfile.ppc64le

+18
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,24 @@ RUN set -x \
197197
&& go build -v -o /usr/local/bin/rsrc github.com/akavel/rsrc \
198198
&& rm -rf "$GOPATH"
199199

200+
# Install runc
201+
ENV RUNC_COMMIT bbde9c426ff363d813b8722f0744115c13b408b6
202+
RUN set -x \
203+
&& export GOPATH="$(mktemp -d)" \
204+
&& git clone git://github.com/opencontainers/runc.git "$GOPATH/src/github.com/opencontainers/runc" \
205+
&& cd "$GOPATH/src/github.com/opencontainers/runc" \
206+
&& git checkout -q "$RUNC_COMMIT" \
207+
&& make BUILDTAGS="seccomp apparmor selinux" && make install
208+
209+
# Install containerd
210+
ENV CONTAINERD_COMMIT 7146b01a3d7aaa146414cdfb0a6c96cfba5d9091
211+
RUN set -x \
212+
&& export GOPATH="$(mktemp -d)" \
213+
&& git clone git://github.com/docker/containerd.git "$GOPATH/src/github.com/docker/containerd" \
214+
&& cd "$GOPATH/src/github.com/docker/containerd" \
215+
&& git checkout -q "$CONTAINERD_COMMIT" \
216+
&& make && make install
217+
200218
# Wrap all commands in the "docker-in-docker" script to allow nested containers
201219
ENTRYPOINT ["hack/dind"]
202220

Dockerfile.s390x

+18
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,24 @@ RUN set -x \
176176
&& go build -v -o /usr/local/bin/rsrc github.com/akavel/rsrc \
177177
&& rm -rf "$GOPATH"
178178

179+
# Install runc
180+
ENV RUNC_COMMIT bbde9c426ff363d813b8722f0744115c13b408b6
181+
RUN set -x \
182+
&& export GOPATH="$(mktemp -d)" \
183+
&& git clone git://github.com/opencontainers/runc.git "$GOPATH/src/github.com/opencontainers/runc" \
184+
&& cd "$GOPATH/src/github.com/opencontainers/runc" \
185+
&& git checkout -q "$RUNC_COMMIT" \
186+
&& make BUILDTAGS="seccomp apparmor selinux" && make install
187+
188+
# Install containerd
189+
ENV CONTAINERD_COMMIT 7146b01a3d7aaa146414cdfb0a6c96cfba5d9091
190+
RUN set -x \
191+
&& export GOPATH="$(mktemp -d)" \
192+
&& git clone git://github.com/docker/containerd.git "$GOPATH/src/github.com/docker/containerd" \
193+
&& cd "$GOPATH/src/github.com/docker/containerd" \
194+
&& git checkout -q "$CONTAINERD_COMMIT" \
195+
&& make && make install
196+
179197
# Wrap all commands in the "docker-in-docker" script to allow nested containers
180198
ENTRYPOINT ["hack/dind"]
181199

Dockerfile.simple

+18
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,24 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
2929
aufs-tools \
3030
&& rm -rf /var/lib/apt/lists/*
3131

32+
# Install runc
33+
ENV RUNC_COMMIT bbde9c426ff363d813b8722f0744115c13b408b6
34+
RUN set -x \
35+
&& export GOPATH="$(mktemp -d)" \
36+
&& git clone git://github.com/opencontainers/runc.git "$GOPATH/src/github.com/opencontainers/runc" \
37+
&& cd "$GOPATH/src/github.com/opencontainers/runc" \
38+
&& git checkout -q "$RUNC_COMMIT" \
39+
&& make BUILDTAGS="seccomp apparmor selinux" && make install
40+
41+
# Install containerd
42+
ENV CONTAINERD_COMMIT 7146b01a3d7aaa146414cdfb0a6c96cfba5d9091
43+
RUN set -x \
44+
&& export GOPATH="$(mktemp -d)" \
45+
&& git clone git://github.com/docker/containerd.git "$GOPATH/src/github.com/docker/containerd" \
46+
&& cd "$GOPATH/src/github.com/docker/containerd" \
47+
&& git checkout -q "$CONTAINERD_COMMIT" \
48+
&& make && make install
49+
3250
ENV AUTO_GOPATH 1
3351
WORKDIR /usr/src/docker
3452
COPY . /usr/src/docker

api/client/run.go

-11
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
"github.com/docker/docker/opts"
1515
"github.com/docker/docker/pkg/promise"
1616
"github.com/docker/docker/pkg/signal"
17-
"github.com/docker/docker/pkg/stringid"
1817
runconfigopts "github.com/docker/docker/runconfig/opts"
1918
"github.com/docker/engine-api/types"
2019
"github.com/docker/libnetwork/resolvconf/dns"
@@ -256,16 +255,6 @@ func (cli *DockerCli) CmdRun(args ...string) error {
256255

257256
// Attached mode
258257
if *flAutoRemove {
259-
// Warn user if they detached us
260-
js, err := cli.client.ContainerInspect(context.Background(), createResponse.ID)
261-
if err != nil {
262-
return runStartContainerErr(err)
263-
}
264-
if js.State.Running == true || js.State.Paused == true {
265-
fmt.Fprintf(cli.out, "Detached from %s, awaiting its termination in order to uphold \"--rm\".\n",
266-
stringid.TruncateID(createResponse.ID))
267-
}
268-
269258
// Autoremove: wait for the container to finish, retrieve
270259
// the exit code and remove the container
271260
if status, err = cli.client.ContainerWait(context.Background(), createResponse.ID); err != nil {

api/server/router/container/exec.go

+2
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,9 @@ func (s *containerRouter) postContainerExecStart(ctx context.Context, w http.Res
112112
if execStartCheck.Detach {
113113
return err
114114
}
115+
stdout.Write([]byte(err.Error()))
115116
logrus.Errorf("Error running exec in container: %v\n", err)
117+
return err
116118
}
117119
return nil
118120
}

container/container.go

+32-29
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717

1818
"github.com/Sirupsen/logrus"
1919
"github.com/docker/docker/daemon/exec"
20-
"github.com/docker/docker/daemon/execdriver"
2120
"github.com/docker/docker/daemon/logger"
2221
"github.com/docker/docker/daemon/logger/jsonfilelog"
2322
"github.com/docker/docker/daemon/network"
@@ -27,6 +26,7 @@ import (
2726
"github.com/docker/docker/pkg/promise"
2827
"github.com/docker/docker/pkg/signal"
2928
"github.com/docker/docker/pkg/symlink"
29+
"github.com/docker/docker/restartmanager"
3030
"github.com/docker/docker/runconfig"
3131
runconfigopts "github.com/docker/docker/runconfig/opts"
3232
"github.com/docker/docker/volume"
@@ -74,13 +74,12 @@ type CommonContainer struct {
7474
HasBeenManuallyStopped bool // used for unless-stopped restart policy
7575
MountPoints map[string]*volume.MountPoint
7676
HostConfig *containertypes.HostConfig `json:"-"` // do not serialize the host config in the json, otherwise we'll make the container unportable
77-
Command *execdriver.Command `json:"-"`
78-
monitor *containerMonitor
79-
ExecCommands *exec.Store `json:"-"`
77+
ExecCommands *exec.Store `json:"-"`
8078
// logDriver for closing
81-
LogDriver logger.Logger `json:"-"`
82-
LogCopier *logger.Copier `json:"-"`
83-
attachContext *attachContext
79+
LogDriver logger.Logger `json:"-"`
80+
LogCopier *logger.Copier `json:"-"`
81+
restartManager restartmanager.RestartManager
82+
attachContext *attachContext
8483
}
8584

8685
// NewBaseContainer creates a new container with its
@@ -276,19 +275,9 @@ func (container *Container) GetRootResourcePath(path string) (string, error) {
276275
// ExitOnNext signals to the monitor that it should not restart the container
277276
// after we send the kill signal.
278277
func (container *Container) ExitOnNext() {
279-
container.monitor.ExitOnNext()
280-
}
281-
282-
// Resize changes the TTY of the process running inside the container
283-
// to the given height and width. The container must be running.
284-
func (container *Container) Resize(h, w int) error {
285-
if container.Command.ProcessConfig.Terminal == nil {
286-
return fmt.Errorf("Container %s does not have a terminal ready", container.ID)
287-
}
288-
if err := container.Command.ProcessConfig.Terminal.Resize(h, w); err != nil {
289-
return err
278+
if container.restartManager != nil {
279+
container.restartManager.Cancel()
290280
}
291-
return nil
292281
}
293282

294283
// HostConfigPath returns the path to the container's JSON hostconfig
@@ -897,19 +886,33 @@ func (container *Container) BuildCreateEndpointOptions(n libnetwork.Network, epC
897886

898887
// UpdateMonitor updates monitor configure for running container
899888
func (container *Container) UpdateMonitor(restartPolicy containertypes.RestartPolicy) {
900-
monitor := container.monitor
901-
// No need to update monitor if container hasn't got one
902-
// monitor will be generated correctly according to container
903-
if monitor == nil {
904-
return
889+
type policySetter interface {
890+
SetPolicy(containertypes.RestartPolicy)
891+
}
892+
893+
if rm, ok := container.RestartManager(false).(policySetter); ok {
894+
rm.SetPolicy(restartPolicy)
895+
}
896+
}
897+
898+
// FullHostname returns hostname and optional domain appended to it.
899+
func (container *Container) FullHostname() string {
900+
fullHostname := container.Config.Hostname
901+
if container.Config.Domainname != "" {
902+
fullHostname = fmt.Sprintf("%s.%s", fullHostname, container.Config.Domainname)
905903
}
904+
return fullHostname
905+
}
906906

907-
monitor.mux.Lock()
908-
// to check whether restart policy has changed.
909-
if restartPolicy.Name != "" && !monitor.restartPolicy.IsSame(&restartPolicy) {
910-
monitor.restartPolicy = restartPolicy
907+
// RestartManager returns the current restartmanager instace connected to container.
908+
func (container *Container) RestartManager(reset bool) restartmanager.RestartManager {
909+
if reset {
910+
container.RestartCount = 0
911+
}
912+
if container.restartManager == nil {
913+
container.restartManager = restartmanager.New(container.HostConfig.RestartPolicy)
911914
}
912-
monitor.mux.Unlock()
915+
return container.restartManager
913916
}
914917

915918
type attachContext struct {

0 commit comments

Comments
 (0)