Skip to content

Commit

Permalink
Adds a log configuration to docker containers such that max size of t…
Browse files Browse the repository at this point in the history
…he container is 30m.
  • Loading branch information
anixon604 committed Mar 26, 2024
1 parent 83c037c commit 0f72d16
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions go/common/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ func StartNewContainer(containerName, image string, cmds []string, ports []int,
exposedPorts[nat.Port(fmt.Sprintf("%d/tcp", port))] = struct{}{}
}

// set log rotations
logOptions := map[string]string{
"max-size": "10m",
"max-file": "3",
}

// create the container
resp, err := cli.ContainerCreate(ctx, &container.Config{
Image: image,
Expand All @@ -101,6 +107,7 @@ func StartNewContainer(containerName, image string, cmds []string, ports []int,
PortBindings: portBindings,
Mounts: mountVolumes,
Resources: container.Resources{Devices: deviceMapping},
LogConfig: container.LogConfig{Type: "json-file", Config: logOptions},
},
&network.NetworkingConfig{
EndpointsConfig: map[string]*network.EndpointSettings{
Expand Down

0 comments on commit 0f72d16

Please sign in to comment.