Skip to content
This repository was archived by the owner on Oct 13, 2023. It is now read-only.
14 changes: 4 additions & 10 deletions cmd/dockerd/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,14 +208,10 @@ func (cli *DaemonCli) start(opts *daemonOptions) (err error) {
return errors.Wrap(err, "failed to validate authorization plugin")
}

// TODO: move into startMetricsServer()
if cli.Config.MetricsAddress != "" {
if !d.HasExperimental() {
return errors.Wrap(err, "metrics-addr is only supported when experimental is enabled")
}
if err := startMetricsServer(cli.Config.MetricsAddress); err != nil {
return err
}
cli.d = d

if err := cli.startMetricsServer(cli.Config.MetricsAddress); err != nil {
return err
}

c, err := createAndStartCluster(cli, d)
Expand All @@ -230,8 +226,6 @@ func (cli *DaemonCli) start(opts *daemonOptions) (err error) {

logrus.Info("Daemon has completed initialization")

cli.d = d

routerOptions, err := newRouterOptions(cli.Config, d)
if err != nil {
return err
Expand Down
11 changes: 10 additions & 1 deletion cmd/dockerd/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,19 @@ import (
"net/http"

"github.com/docker/go-metrics"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)

func startMetricsServer(addr string) error {
func (cli *DaemonCli) startMetricsServer(addr string) error {
if addr == "" {
return nil
}

if !cli.d.HasExperimental() {
return errors.New("metrics-addr is only supported when experimental is enabled")
}

if err := allocateDaemonPort(addr); err != nil {
return err
}
Expand Down
10 changes: 5 additions & 5 deletions integration-cli/check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ import (
"github.com/docker/docker/integration-cli/cli"
"github.com/docker/docker/integration-cli/daemon"
"github.com/docker/docker/integration-cli/environment"
testdaemon "github.com/docker/docker/internal/test/daemon"
ienv "github.com/docker/docker/internal/test/environment"
"github.com/docker/docker/internal/test/fakestorage"
"github.com/docker/docker/internal/test/fixtures/plugin"
"github.com/docker/docker/internal/test/registry"
"github.com/docker/docker/internal/test/suite"
"github.com/docker/docker/pkg/reexec"
testdaemon "github.com/docker/docker/testutil/daemon"
ienv "github.com/docker/docker/testutil/environment"
"github.com/docker/docker/testutil/fakestorage"
"github.com/docker/docker/testutil/fixtures/plugin"
"github.com/docker/docker/testutil/registry"
"gotest.tools/assert"
)

Expand Down
2 changes: 1 addition & 1 deletion integration-cli/cli/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"io"
"strings"

"github.com/docker/docker/internal/test/fakecontext"
"github.com/docker/docker/testutil/fakecontext"
"gotest.tools/icmd"
)

Expand Down
4 changes: 2 additions & 2 deletions integration-cli/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"testing"
"time"

"github.com/docker/docker/internal/test/daemon"
"github.com/docker/docker/testutil/daemon"
"github.com/pkg/errors"
"gotest.tools/assert"
"gotest.tools/icmd"
Expand All @@ -31,7 +31,7 @@ type Daemon struct {
// New returns a Daemon instance to be used for testing.
// This will create a directory such as d123456789 in the folder specified by $DOCKER_INTEGRATION_DAEMON_DEST or $DEST.
// The daemon will not automatically start.
func New(t testingT, dockerBinary string, dockerdBinary string, ops ...func(*daemon.Daemon)) *Daemon {
func New(t testingT, dockerBinary string, dockerdBinary string, ops ...daemon.Option) *Daemon {
ops = append(ops, daemon.WithDockerdBinary(dockerdBinary))
d := daemon.New(t, ops...)
return &Daemon{
Expand Down
2 changes: 1 addition & 1 deletion integration-cli/docker_api_attach_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (

"github.com/docker/docker/api/types"
"github.com/docker/docker/client"
"github.com/docker/docker/internal/test/request"
"github.com/docker/docker/pkg/stdcopy"
"github.com/docker/docker/testutil/request"
"github.com/pkg/errors"
"golang.org/x/net/websocket"
"gotest.tools/assert"
Expand Down
8 changes: 4 additions & 4 deletions integration-cli/docker_api_build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import (
"testing"

"github.com/docker/docker/api/types"
"github.com/docker/docker/internal/test/fakecontext"
"github.com/docker/docker/internal/test/fakegit"
"github.com/docker/docker/internal/test/fakestorage"
"github.com/docker/docker/internal/test/request"
"github.com/docker/docker/testutil/fakecontext"
"github.com/docker/docker/testutil/fakegit"
"github.com/docker/docker/testutil/fakestorage"
"github.com/docker/docker/testutil/request"
"gotest.tools/assert"
is "gotest.tools/assert/cmp"
)
Expand Down
4 changes: 2 additions & 2 deletions integration-cli/docker_api_build_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"net/http"
"testing"

"github.com/docker/docker/internal/test/fakecontext"
"github.com/docker/docker/internal/test/request"
"github.com/docker/docker/testutil/fakecontext"
"github.com/docker/docker/testutil/request"
"gotest.tools/assert"
is "gotest.tools/assert/cmp"
)
Expand Down
2 changes: 1 addition & 1 deletion integration-cli/docker_api_containers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ import (
"github.com/docker/docker/client"
"github.com/docker/docker/integration-cli/cli"
"github.com/docker/docker/integration-cli/cli/build"
"github.com/docker/docker/internal/test/request"
"github.com/docker/docker/pkg/ioutils"
"github.com/docker/docker/pkg/mount"
"github.com/docker/docker/pkg/stringid"
"github.com/docker/docker/testutil/request"
"github.com/docker/docker/volume"
"github.com/docker/go-connections/nat"
"gotest.tools/assert"
Expand Down
2 changes: 1 addition & 1 deletion integration-cli/docker_api_exec_resize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"testing"

"github.com/docker/docker/api/types/versions"
"github.com/docker/docker/internal/test/request"
"github.com/docker/docker/testutil/request"
"gotest.tools/assert"
)

Expand Down
2 changes: 1 addition & 1 deletion integration-cli/docker_api_exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/docker/docker/api/types/versions"
"github.com/docker/docker/client"
"github.com/docker/docker/integration-cli/checker"
"github.com/docker/docker/internal/test/request"
"github.com/docker/docker/testutil/request"
"gotest.tools/assert"
"gotest.tools/poll"
)
Expand Down
2 changes: 1 addition & 1 deletion integration-cli/docker_api_images_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
"github.com/docker/docker/client"
"github.com/docker/docker/integration-cli/cli"
"github.com/docker/docker/integration-cli/cli/build"
"github.com/docker/docker/internal/test/request"
"github.com/docker/docker/pkg/parsers/kernel"
"github.com/docker/docker/testutil/request"
"gotest.tools/assert"
)

Expand Down
2 changes: 1 addition & 1 deletion integration-cli/docker_api_logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (

"github.com/docker/docker/api/types"
"github.com/docker/docker/client"
"github.com/docker/docker/internal/test/request"
"github.com/docker/docker/pkg/stdcopy"
"github.com/docker/docker/testutil/request"
"gotest.tools/assert"
)

Expand Down
2 changes: 1 addition & 1 deletion integration-cli/docker_api_network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/network"
"github.com/docker/docker/api/types/versions"
"github.com/docker/docker/internal/test/request"
"github.com/docker/docker/testutil/request"
"gotest.tools/assert"
)

Expand Down
2 changes: 1 addition & 1 deletion integration-cli/docker_api_stats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/versions"
"github.com/docker/docker/client"
"github.com/docker/docker/internal/test/request"
"github.com/docker/docker/testutil/request"
"gotest.tools/assert"
)

Expand Down
2 changes: 1 addition & 1 deletion integration-cli/docker_api_swarm_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/docker/docker/integration-cli/cli"
"github.com/docker/docker/integration-cli/cli/build"
"github.com/docker/docker/integration-cli/daemon"
testdaemon "github.com/docker/docker/internal/test/daemon"
testdaemon "github.com/docker/docker/testutil/daemon"
"golang.org/x/sys/unix"
"gotest.tools/assert"
"gotest.tools/icmd"
Expand Down
4 changes: 2 additions & 2 deletions integration-cli/docker_api_swarm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import (
"github.com/docker/docker/client"
"github.com/docker/docker/integration-cli/checker"
"github.com/docker/docker/integration-cli/daemon"
testdaemon "github.com/docker/docker/internal/test/daemon"
"github.com/docker/docker/internal/test/request"
testdaemon "github.com/docker/docker/testutil/daemon"
"github.com/docker/docker/testutil/request"
"github.com/docker/swarmkit/ca"
"github.com/pkg/errors"
"gotest.tools/assert"
Expand Down
2 changes: 1 addition & 1 deletion integration-cli/docker_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

"github.com/docker/docker/api"
"github.com/docker/docker/api/types/versions"
"github.com/docker/docker/internal/test/request"
"github.com/docker/docker/testutil/request"
"gotest.tools/assert"
)

Expand Down
8 changes: 4 additions & 4 deletions integration-cli/docker_cli_build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ import (

"github.com/docker/docker/integration-cli/cli"
"github.com/docker/docker/integration-cli/cli/build"
"github.com/docker/docker/internal/test/fakecontext"
"github.com/docker/docker/internal/test/fakegit"
"github.com/docker/docker/internal/test/fakestorage"
"github.com/docker/docker/internal/testutil"
"github.com/docker/docker/pkg/archive"
"github.com/docker/docker/pkg/system"
"github.com/docker/docker/testutil"
"github.com/docker/docker/testutil/fakecontext"
"github.com/docker/docker/testutil/fakegit"
"github.com/docker/docker/testutil/fakestorage"
"github.com/moby/buildkit/frontend/dockerfile/command"
"github.com/opencontainers/go-digest"
"gotest.tools/assert"
Expand Down
2 changes: 1 addition & 1 deletion integration-cli/docker_cli_build_unix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (

"github.com/docker/docker/integration-cli/cli"
"github.com/docker/docker/integration-cli/cli/build"
"github.com/docker/docker/internal/test/fakecontext"
"github.com/docker/docker/testutil/fakecontext"
"github.com/docker/go-units"
"gotest.tools/assert"
"gotest.tools/icmd"
Expand Down
2 changes: 1 addition & 1 deletion integration-cli/docker_cli_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (

"github.com/docker/docker/integration-cli/cli"
"github.com/docker/docker/integration-cli/cli/build"
"github.com/docker/docker/internal/test/fakecontext"
"github.com/docker/docker/pkg/stringid"
"github.com/docker/docker/testutil/fakecontext"
"github.com/docker/go-connections/nat"
"gotest.tools/assert"
is "gotest.tools/assert/cmp"
Expand Down
10 changes: 5 additions & 5 deletions integration-cli/docker_cli_daemon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ import (
"github.com/docker/docker/integration-cli/cli"
"github.com/docker/docker/integration-cli/cli/build"
"github.com/docker/docker/integration-cli/daemon"
testdaemon "github.com/docker/docker/internal/test/daemon"
"github.com/docker/docker/opts"
"github.com/docker/docker/pkg/mount"
testdaemon "github.com/docker/docker/testutil/daemon"
"github.com/docker/go-units"
"github.com/docker/libnetwork/iptables"
"github.com/docker/libtrust"
Expand Down Expand Up @@ -427,7 +427,7 @@ func (s *DockerDaemonSuite) TestDaemonIPv6FixedCIDR(c *testing.T) {

s.d.StartWithBusybox(c, "--ipv6", "--fixed-cidr-v6=2001:db8:2::/64", "--default-gateway-v6=2001:db8:2::100")

out, err := s.d.Cmd("run", "-itd", "--name=ipv6test", "busybox:latest")
out, err := s.d.Cmd("run", "-d", "--name=ipv6test", "busybox:latest", "top")
assert.NilError(c, err, "Could not run container: %s, %v", out, err)

out, err = s.d.Cmd("inspect", "--format", "{{.NetworkSettings.Networks.bridge.GlobalIPv6Address}}", "ipv6test")
Expand All @@ -454,7 +454,7 @@ func (s *DockerDaemonSuite) TestDaemonIPv6FixedCIDRAndMac(c *testing.T) {

s.d.StartWithBusybox(c, "--ipv6", "--fixed-cidr-v6=2001:db8:1::/64")

out, err := s.d.Cmd("run", "-itd", "--name=ipv6test", "--mac-address", "AA:BB:CC:DD:EE:FF", "busybox")
out, err := s.d.Cmd("run", "-d", "--name=ipv6test", "--mac-address", "AA:BB:CC:DD:EE:FF", "busybox", "top")
assert.NilError(c, err, out)

out, err = s.d.Cmd("inspect", "--format", "{{.NetworkSettings.Networks.bridge.GlobalIPv6Address}}", "ipv6test")
Expand All @@ -469,7 +469,7 @@ func (s *DockerDaemonSuite) TestDaemonIPv6HostMode(c *testing.T) {
deleteInterface(c, "docker0")

s.d.StartWithBusybox(c, "--ipv6", "--fixed-cidr-v6=2001:db8:2::/64")
out, err := s.d.Cmd("run", "-itd", "--name=hostcnt", "--network=host", "busybox:latest")
out, err := s.d.Cmd("run", "-d", "--name=hostcnt", "--network=host", "busybox:latest", "top")
assert.NilError(c, err, "Could not run container: %s, %v", out, err)

out, err = s.d.Cmd("exec", "hostcnt", "ip", "-6", "addr", "show", "docker0")
Expand Down Expand Up @@ -2703,7 +2703,7 @@ func (s *DockerDaemonSuite) TestExecWithUserAfterLiveRestore(c *testing.T) {
testRequires(c, DaemonIsLinux)
s.d.StartWithBusybox(c, "--live-restore")

out, err := s.d.Cmd("run", "-d", "--name=top", "busybox", "sh", "-c", "addgroup -S test && adduser -S -G test test -D -s /bin/sh && touch /adduser_end && top")
out, err := s.d.Cmd("run", "--init", "-d", "--name=top", "busybox", "sh", "-c", "addgroup -S test && adduser -S -G test test -D -s /bin/sh && touch /adduser_end && exec top")
assert.NilError(c, err, "Output: %s", out)

s.d.WaitRun("top")
Expand Down
2 changes: 1 addition & 1 deletion integration-cli/docker_cli_external_volume_driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import (

"github.com/docker/docker/api/types"
"github.com/docker/docker/integration-cli/daemon"
testdaemon "github.com/docker/docker/internal/test/daemon"
"github.com/docker/docker/pkg/stringid"
testdaemon "github.com/docker/docker/testutil/daemon"
"github.com/docker/docker/volume"
"gotest.tools/assert"
)
Expand Down
2 changes: 1 addition & 1 deletion integration-cli/docker_cli_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"testing"

"github.com/docker/docker/integration-cli/daemon"
testdaemon "github.com/docker/docker/internal/test/daemon"
testdaemon "github.com/docker/docker/testutil/daemon"
"gotest.tools/assert"
)

Expand Down
6 changes: 3 additions & 3 deletions integration-cli/docker_cli_network_unix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import (
"github.com/docker/docker/api/types/versions/v1p20"
"github.com/docker/docker/integration-cli/cli"
"github.com/docker/docker/integration-cli/daemon"
testdaemon "github.com/docker/docker/internal/test/daemon"
"github.com/docker/docker/pkg/stringid"
"github.com/docker/docker/runconfig"
testdaemon "github.com/docker/docker/testutil/daemon"
"github.com/docker/libnetwork/driverapi"
remoteapi "github.com/docker/libnetwork/drivers/remote/api"
"github.com/docker/libnetwork/ipamapi"
Expand Down Expand Up @@ -956,7 +956,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkDriverUngracefulRestart(c *testing
_, err := s.d.Cmd("network", "create", "-d", dnd, "--subnet", "1.1.1.0/24", "net1")
assert.NilError(c, err)

_, err = s.d.Cmd("run", "-itd", "--net", "net1", "--name", "foo", "--ip", "1.1.1.10", "busybox", "sh")
_, err = s.d.Cmd("run", "-d", "--net", "net1", "--name", "foo", "--ip", "1.1.1.10", "busybox", "top")
assert.NilError(c, err)

// Kill daemon and restart
Expand All @@ -980,7 +980,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkDriverUngracefulRestart(c *testing
setupRemoteNetworkDrivers(c, mux, server.URL, dnd, did)

// trying to reuse the same ip must succeed
_, err = s.d.Cmd("run", "-itd", "--net", "net1", "--name", "bar", "--ip", "1.1.1.10", "busybox", "sh")
_, err = s.d.Cmd("run", "-d", "--net", "net1", "--name", "bar", "--ip", "1.1.1.10", "busybox", "top")
assert.NilError(c, err)
}

Expand Down
2 changes: 1 addition & 1 deletion integration-cli/docker_cli_plugins_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/docker/docker/api/types"
"github.com/docker/docker/integration-cli/cli"
"github.com/docker/docker/integration-cli/daemon"
"github.com/docker/docker/internal/test/fixtures/plugin"
"github.com/docker/docker/testutil/fixtures/plugin"
"gotest.tools/assert"
)

Expand Down
2 changes: 1 addition & 1 deletion integration-cli/docker_cli_registry_user_agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"regexp"
"testing"

"github.com/docker/docker/internal/test/registry"
"github.com/docker/docker/testutil/registry"
"gotest.tools/assert"
)

Expand Down
4 changes: 2 additions & 2 deletions integration-cli/docker_cli_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ import (
"github.com/docker/docker/client"
"github.com/docker/docker/integration-cli/cli"
"github.com/docker/docker/integration-cli/cli/build"
"github.com/docker/docker/internal/test/fakecontext"
"github.com/docker/docker/internal/testutil"
"github.com/docker/docker/pkg/mount"
"github.com/docker/docker/pkg/parsers/kernel"
"github.com/docker/docker/pkg/stringid"
"github.com/docker/docker/runconfig"
"github.com/docker/docker/testutil"
"github.com/docker/docker/testutil/fakecontext"
"github.com/docker/go-connections/nat"
"github.com/docker/libnetwork/resolvconf"
"github.com/docker/libnetwork/types"
Expand Down
Loading