Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log docker server info #548

Merged
merged 5 commits into from Oct 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 24 additions & 0 deletions docker.go
Expand Up @@ -15,6 +15,7 @@ import (
"os/exec"
"path/filepath"
"strings"
"sync"
"time"

"github.com/docker/docker/api/types/filters"
Expand All @@ -40,13 +41,15 @@ var (
// Implement interfaces
_ Container = (*DockerContainer)(nil)

logOnce sync.Once
ErrDuplicateMountTarget = errors.New("duplicate mount target detected")
)

const (
Bridge = "bridge" // Bridge network name (as well as driver)
Podman = "podman"
ReaperDefault = "reaper_default" // Default network name when bridge is not available
packagePath = "github.com/testcontainers/testcontainers-go"
)

// DockerContainer represents a container started using Docker
Expand Down Expand Up @@ -770,9 +773,30 @@ func NewDockerProvider(provOpts ...DockerProviderOption) (*DockerProvider, error
config: tcConfig,
}

// log docker server info only once
logOnce.Do(p.logDockerServerInfo)

return p, nil
}

func (p *DockerProvider) logDockerServerInfo() {
infoMessage := `%v - Connected to docker:
Server Version: %v
API Version: %v
Operating System: %v
Total Memory: %v MB
`

info, err := p.client.Info(context.Background())
if err != nil {
p.Logger.Printf("failed getting information about docker server: %s", err)
}

p.Logger.Printf(infoMessage, packagePath,
info.ServerVersion, p.client.ClientVersion(),
info.OperatingSystem, info.MemTotal/1024/1024)
}

// configureTC reads from testcontainers properties file, if it exists
// it is possible that certain values get overridden when set as environment variables
func configureTC() TestContainersConfig {
Expand Down
46 changes: 39 additions & 7 deletions go.mod
Expand Up @@ -4,26 +4,58 @@ go 1.18

require (
github.com/cenkalti/backoff/v4 v4.1.3
github.com/containerd/cgroups v1.0.4 // indirect
github.com/containerd/containerd v1.6.8
github.com/containerd/continuity v0.3.0 // indirect
github.com/docker/distribution v2.8.1+incompatible // indirect
github.com/docker/docker v20.10.17+incompatible
github.com/docker/go-connections v0.4.0
github.com/docker/go-units v0.5.0
github.com/go-redis/redis/v8 v8.11.5
github.com/go-sql-driver/mysql v1.6.0
github.com/google/uuid v1.3.0
github.com/magiconair/properties v1.8.6
github.com/moby/sys/mount v0.3.3 // indirect
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6
github.com/opencontainers/image-spec v1.0.3-0.20211202183452-c5a74bcca799
github.com/opencontainers/runc v1.1.3 // indirect
github.com/stretchr/testify v1.8.0
golang.org/x/net v0.0.0-20220617184016-355a448f1bc9 // indirect
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8
google.golang.org/genproto v0.0.0-20220617124728-180714bec0ad // indirect
gopkg.in/yaml.v3 v3.0.1
gotest.tools/gotestsum v1.8.2
gotest.tools/v3 v3.3.0
)

require (
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/Microsoft/go-winio v0.5.2 // indirect
github.com/Microsoft/hcsshim v0.9.4 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/containerd/cgroups v1.0.4 // indirect
github.com/containerd/continuity v0.3.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/dnephin/pflag v1.0.7 // indirect
github.com/docker/distribution v2.8.1+incompatible // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/moby/sys/mount v0.3.3 // indirect
github.com/moby/sys/mountinfo v0.6.2 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/runc v1.1.3 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
go.opencensus.io v0.23.0 // indirect
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
golang.org/x/net v0.0.0-20220617184016-355a448f1bc9 // indirect
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f // indirect
golang.org/x/term v0.0.0-20220526004731-065cf7ba2467 // indirect
golang.org/x/tools v0.1.11 // indirect
google.golang.org/genproto v0.0.0-20220617124728-180714bec0ad // indirect
google.golang.org/grpc v1.47.0 // indirect
google.golang.org/protobuf v1.28.0 // indirect
)