MCPcopy Index your code
hub / github.com/testcontainers/testcontainers-go / ExampleDockerProvider_CreateContainer

Function ExampleDockerProvider_CreateContainer

docker_test.go:697–724  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

695}
696
697func ExampleDockerProvider_CreateContainer() {
698 ctx := context.Background()
699 nginxC, err := Run(
700 ctx, nginxAlpineImage,
701 WithExposedPorts("80/tcp"),
702 WithWaitStrategy(wait.ForHTTP("/").WithStartupTimeout(10*time.Second)),
703 )
704 defer func() {
705 if err := TerminateContainer(nginxC); err != nil {
706 log.Printf("failed to terminate container: %s", err)
707 }
708 }()
709 if err != nil {
710 log.Printf("failed to create container: %s", err)
711 return
712 }
713
714 state, err := nginxC.State(ctx)
715 if err != nil {
716 log.Printf("failed to get container state: %s", err)
717 return
718 }
719
720 fmt.Println(state.Running)
721
722 // Output:
723 // true
724}
725
726func ExampleContainer_Host() {
727 ctx := context.Background()

Callers

nothing calls this directly

Calls 8

ForHTTPFunction · 0.92
PrintfFunction · 0.92
WithExposedPortsFunction · 0.85
WithWaitStrategyFunction · 0.85
TerminateContainerFunction · 0.85
RunFunction · 0.70
StateMethod · 0.65
WithStartupTimeoutMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…