Skip to content

Commit

Permalink
docs: consistency with tab indents
Browse files Browse the repository at this point in the history
  • Loading branch information
mdelapenya committed Jul 6, 2022
1 parent 88a3ddf commit 81567e6
Showing 1 changed file with 28 additions and 19 deletions.
47 changes: 28 additions & 19 deletions docs/features/creating_container.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,51 +91,60 @@ the function will create a new generic container. If `Reuse` is true and `Name`

The following test creates an NGINX container, adds a file into it and then reuses the container again for checking the file:
```go
package main

import (
"context"
"fmt"
"log"

"github.com/testcontainers/testcontainers-go"
)

const (
reusableContainerName = "my_test_reusable_container"
reusableContainerName = "my_test_reusable_container"
)

ctx := context.Background()

n1, err := GenericContainer(ctx, GenericContainerRequest{
ContainerRequest: ContainerRequest{
Image: "nginx:1.17.6",
ExposedPorts: []string{"80/tcp"},
WaitingFor: wait.ForListeningPort("80/tcp"),
Name: reusableContainerName,
},
Started: true,
ContainerRequest: ContainerRequest{
Image: "nginx:1.17.6",
ExposedPorts: []string{"80/tcp"},
WaitingFor: wait.ForListeningPort("80/tcp"),
Name: reusableContainerName,
},
Started: true,
})
if err != nil {
log.Fatal(err)
log.Fatal(err)
}
defer n1.Terminate(ctx)

copiedFileName := "hello_copy.sh"
err = n1.CopyFileToContainer(ctx, "./testresources/hello.sh", "/"+copiedFileName, 700)

if err != nil {
log.Fatal(err)
log.Fatal(err)
}

n2, err := GenericContainer(ctx, GenericContainerRequest{
ContainerRequest: ContainerRequest{
Image: "nginx:1.17.6",
ExposedPorts: []string{"80/tcp"},
WaitingFor: wait.ForListeningPort("80/tcp"),
Name: reusableContainerName,
ContainerRequest: ContainerRequest{
Image: "nginx:1.17.6",
ExposedPorts: []string{"80/tcp"},
WaitingFor: wait.ForListeningPort("80/tcp"),
Name: reusableContainerName,
},
Started: true,
Started: true,
Reuse: true,
})
if err != nil {
log.Fatal(err)
log.Fatal(err)
}

c, _, err := n2.Exec(ctx, []string{"bash", copiedFileName})
if err != nil {
log.Fatal(err)
log.Fatal(err)
}
fmt.Println(c)
```
Expand Down Expand Up @@ -201,4 +210,4 @@ func main() {
defer c.Terminate(ctx)
}
}
```
```

0 comments on commit 81567e6

Please sign in to comment.