Created
July 29, 2019 11:34
-
-
Save orcaman/2ab02914db461a5b98b74a1835ea7119 to your computer and use it in GitHub Desktop.
Redirecting Docker Logs Driver to GCP StackDriver Logs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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