{"modulePath":"github.com/smartcontractkit/chainlink-testing-framework/lib","version":"v1.54.9","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package docker\n\n## Constants\n\n```go\nconst RetryAttempts = 3\n```\n\n## Variables\n\n```go\nvar LinuxPlatformImageRetrier = func(l zerolog.Logger, startErr error, req tc.GenericContainerRequest) (tc.Container, error) {\n\n\tif startErr == nil {\n\t\treturn nil, startErr\n\t}\n\n\treq.Reuse = false\n\n\tif !strings.Contains(startErr.Error(), \"No such image\") {\n\t\tl.Debug().\n\t\t\tStr(\"Start error\", startErr.Error()).\n\t\t\tStr(\"Retrier\", \"PlatformImageRetrier\").\n\t\t\tMsgf(\"Won't try to start %s container again, unsupported error\", req.Name)\n\t\treturn nil, startErr\n\t}\n\n\tl.Debug().\n\t\tStr(\"Start error\", startErr.Error()).\n\t\tStr(\"Retrier\", \"PlatformImageRetrier\").\n\t\tMsgf(\"Attempting to start %s container\", req.Name)\n\n\toriginalPlatform := req.ImagePlatform\n\treq.ImagePlatform = \"linux/x86_64\"\n\n\tremoveErr := removeContainer(req)\n\tif removeErr != nil {\n\t\tl.Error().Err(removeErr).Msgf(\"Failed to remove %s container to initiate restart\", req.Name)\n\t\treturn nil, removeErr\n\t}\n\n\tct, err := tc.GenericContainer(testcontext.Get(nil), req)\n\tif err == nil {\n\t\tl.Debug().\n\t\t\tStr(\"Retrier\", \"PlatformImageRetrier\").\n\t\t\tMsgf(\"Successfully started %s container\", req.Name)\n\t\treturn ct, nil\n\t}\n\n\treq.ImagePlatform = originalPlatform\n\n\tif ct != nil {\n\t\terr := ct.Terminate(testcontext.Get(nil))\n\t\tif err != nil {\n\t\t\tl.Error().Err(err).Msgf(\"Cannot terminate %s container to initiate restart\", req.Name)\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tl.Debug().\n\t\tStr(\"Original start error\", startErr.Error()).\n\t\tStr(\"Current start error\", err.Error()).\n\t\tStr(\"Retrier\", \"PlatformImageRetrier\").\n\t\tMsgf(\"Failed to start %s container,\", req.Name)\n\n\treturn nil, startErr\n}\n```\n\n```go\nvar NaiveRetrier = func(l zerolog.Logger, startErr error, req tc.GenericContainerRequest) (tc.Container, error) {\n\tl.Debug().\n\t\tStr(\"Start error\", startErr.Error()).\n\t\tStr(\"Retrier\", \"NaiveRetrier\").\n\t\tMsgf(\"Attempting to start %s container\", req.Name)\n\n\treq.Reuse = false\n\n\tremoveErr := removeContainer(req)\n\tif removeErr != nil {\n\t\tl.Error().Err(removeErr).Msgf(\"Failed to remove %s container to initiate restart\", req.Name)\n\t\treturn nil, removeErr\n\t}\n\n\tct, err := tc.GenericContainer(testcontext.Get(nil), req)\n\tif err == nil {\n\t\tl.Debug().\n\t\t\tStr(\"Retrier\", \"NaiveRetrier\").\n\t\t\tMsgf(\"Successfully started %s container\", req.Name)\n\t\treturn ct, nil\n\t}\n\tif ct != nil {\n\t\terr := ct.Terminate(testcontext.Get(nil))\n\t\tif err != nil {\n\t\t\tl.Error().\n\t\t\t\tErr(err).\n\t\t\t\tMsgf(\"Cannot terminate %s container to initiate restart\", req.Name)\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tl.Debug().\n\t\tStr(\"Original start error\", startErr.Error()).\n\t\tStr(\"Current start error\", err.Error()).\n\t\tStr(\"Retrier\", \"NaiveRetrier\").\n\t\tMsgf(\"Failed to start %s container,\", req.Name)\n\n\treturn nil, startErr\n}\n```\n\n## Functions\n\n```go\nfunc CreateNetwork(l zerolog.Logger) (*tc.DockerNetwork, error)\n```\nCreateNetwork initializes a new Docker network with a unique name. It ensures no duplicate networks exist and returns the created network or an error if the operation fails.\n\n```go\nfunc StartContainerWithRetry(l zerolog.Logger, req tc.GenericContainerRequest, retriers ...StartContainerRetrier) (tc.Container, error)\n```\nStartContainerWithRetry attempts to start a container with 3 retry attempts. It will try to start the container with the provided retriers, if none are provided it will use the default retriers. Default being: 1. tries to download image for \"linux/x86\\_64\" platform 2. simply starts again without changing anything\n\n```go\nfunc WriteAllContainersLogs(logger zerolog.Logger, directory string) error\n```\nWriteAllContainersLogs writes all Docker container logs to the default logs directory\n\n## Types\n\n```go\ntype StartContainerRetrier func(l zerolog.Logger, startErr error, req tc.GenericContainerRequest) (tc.Container, error)\n```\n\n","path":"github.com/smartcontractkit/chainlink-testing-framework/lib/docker","name":"docker","synopsis":"","isRedistributable":true}
