Skip to content

Instantly share code, notes, and snippets.

@orcaman
Created July 29, 2019 11:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save orcaman/2ab02914db461a5b98b74a1835ea7119 to your computer and use it in GitHub Desktop.
Save orcaman/2ab02914db461a5b98b74a1835ea7119 to your computer and use it in GitHub Desktop.
Redirecting Docker Logs Driver to GCP StackDriver Logs
ctx := context.Background()
cli, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
if err != nil {
return err
}
resp, err := cli.ContainerCreate(ctx, &container.Config{
Image: image,
Env: env,
Tty: true,
AttachStderr: true,
AttachStdin: true,
AttachStdout: true,
}, &container.HostConfig{
LogConfig: container.LogConfig{
Type: "gcplogs",
Config: map[string]string{"gcp-log-cmd": "true"},
},
}, nil, "")
if err != nil {
return err
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment