{"id":16570993,"url":"https://github.com/opalmer/dockertest","last_synced_at":"2026-04-20T14:35:36.545Z","repository":{"id":57492002,"uuid":"73227108","full_name":"opalmer/dockertest","owner":"opalmer","description":"Provides APIs for running, querying and setting up docker containers for local testing.","archived":false,"fork":false,"pushed_at":"2020-09-30T22:54:16.000Z","size":518,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-05T14:17:59.666Z","etag":null,"topics":["developer-tools","docker","go","golang"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/opalmer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-11-08T21:08:00.000Z","updated_at":"2024-05-21T02:51:15.000Z","dependencies_parsed_at":"2022-08-28T11:50:15.884Z","dependency_job_id":null,"html_url":"https://github.com/opalmer/dockertest","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/opalmer/dockertest","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opalmer%2Fdockertest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opalmer%2Fdockertest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opalmer%2Fdockertest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opalmer%2Fdockertest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/opalmer","download_url":"https://codeload.github.com/opalmer/dockertest/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opalmer%2Fdockertest/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32050976,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-20T11:35:06.609Z","status":"ssl_error","status_checked_at":"2026-04-20T11:34:48.899Z","response_time":94,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["developer-tools","docker","go","golang"],"created_at":"2024-10-11T21:20:48.297Z","updated_at":"2026-04-20T14:35:36.526Z","avatar_url":"https://github.com/opalmer.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Docker Test\n\n[![Build Status](https://travis-ci.org/opalmer/dockertest.svg?branch=master)](https://travis-ci.org/opalmer/dockertest)\n[![codecov](https://codecov.io/gh/opalmer/dockertest/branch/master/graph/badge.svg)](https://codecov.io/gh/opalmer/dockertest)\n[![Go Report Card](https://goreportcard.com/badge/github.com/opalmer/dockertest)](https://goreportcard.com/report/github.com/opalmer/dockertest)\n[![GoDoc](https://godoc.org/github.com/opalmer/dockertest?status.svg)](https://godoc.org/github.com/opalmer/dockertest)\n\nThis project provides a small set of wrappers around docker. It is intended\nto be used to ease testing. Documentation is available via godoc: \n    https://godoc.org/github.com/opalmer/dockertest\n\n# Examples\n\nCreate a container and retrieve an exposed port.\n\n```go\nimport (\n\t\"context\"\n\t\"log\"\n\t\"github.com/opalmer/dockertest\"\n)\n\nfunc main() {\n\tclient, err := dockertest.NewClient()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\t// Construct information about the container to start.\n\tinput := dockertest.NewClientInput(\"nginx:mainline-alpine\")\n\tinput.Ports.Add(\u0026dockertest.Port{\n\t\tPrivate:  80,\n\t\tPublic:   dockertest.RandomPort,\n\t\tProtocol: dockertest.ProtocolTCP,\n\t})\n\n\t// Start the container\n\tcontainer, err := client.RunContainer(context.Background(), input)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\t// Extract information about the started container.\n\tport, err := container.Port(80)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tfmt.Println(port.Public, port.Address)\n\n\tif err := client.RemoveContainer(context.Background(), container.ID()); err != nil {\n\t\tlog.Fatal(err)\n\t}\n}\n```\n\nCreate a container using the `Service` struct.\n\n```go\nimport (\n\t\"context\"\n\t\"log\"\n\t\"github.com/opalmer/dockertest\"\n)\n\nfunc main() {\n\tclient, err := dockertest.NewClient()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\t// Construct information about the container to start.\n\tinput := dockertest.NewClientInput(\"nginx:mainline-alpine\")\n\tinput.Ports.Add(\u0026dockertest.Port{\n\t\tPrivate:  80,\n\t\tPublic:   dockertest.RandomPort,\n\t\tProtocol: dockertest.ProtocolTCP,\n\t})\n\n\t// Construct the service and tell it how to handle waiting\n\t// for the container to start.\n\tservice := client.Service(input)\n\tservice.Ping = func(input *dockertest.PingInput) error {\n\t\tport, err := input.Container.Port(80)\n\t\tif err != nil {\n\t\t\treturn err // Will cause Run() to call Terminate()\n\t\t}\n\n\t\tfor {\n\t\t\t_, err := net.Dial(string(port.Protocol), fmt.Sprintf(\"%s:%d\", port.Address, port.Public))\n\t\t\tif err != nil {\n\t\t\t\ttime.Sleep(time.Millisecond * 100)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\n\t\treturn nil\n\t}\n\n\t// Starts the container, runs Ping() and waits for it to return. If Ping()\n\t// fails the container will be terminated and Run() will return an error.\n\tif err := service.Run(); err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\t// Container has started, get information information\n\t// about the exposed port.\n\tport, err := service.Container.Port(80)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tfmt.Println(port.Public, port.Address)\n\n\tif err := service.Terminate(); err != nil {\n\t\tlog.Fatal(err)\n\t}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopalmer%2Fdockertest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopalmer%2Fdockertest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopalmer%2Fdockertest/lists"}