mirror of
https://github.com/vmorganp/Lazytainer.git
synced 2025-12-31 10:07:28 +01:00
Added API version negotiation to group.go (#28)
* Update lazytainer.go Negotiate docker API version to prevent "client version is too new" error * Update group.go negotiate docker API version
This commit is contained in:
@@ -74,6 +74,7 @@ func (lg LazyGroup) MainLoop() {
|
||||
func (lg LazyGroup) getContainers() []types.Container {
|
||||
dockerClient, err := client.NewClientWithOpts(client.FromEnv)
|
||||
check(err)
|
||||
dockerClient.NegotiateAPIVersion(context.Background())
|
||||
filter := filters.NewArgs(filters.Arg("label", "lazytainer.group="+lg.groupName))
|
||||
containers, err := dockerClient.ContainerList(context.Background(), types.ContainerListOptions{All: true, Filters: filter})
|
||||
check(err)
|
||||
@@ -85,6 +86,7 @@ func (lg LazyGroup) stopContainers() {
|
||||
debugLogger.Println("stopping container(s)")
|
||||
dockerClient, err := client.NewClientWithOpts(client.FromEnv)
|
||||
check(err)
|
||||
dockerClient.NegotiateAPIVersion(context.Background())
|
||||
for _, c := range lg.getContainers() {
|
||||
if lg.sleepMethod == "stop" || lg.sleepMethod == "" {
|
||||
if err := dockerClient.ContainerStop(context.Background(), c.ID, container.StopOptions{}); err != nil {
|
||||
@@ -106,6 +108,7 @@ func (lg LazyGroup) startContainers() {
|
||||
debugLogger.Println("starting container(s)")
|
||||
dockerClient, err := client.NewClientWithOpts(client.FromEnv)
|
||||
check(err)
|
||||
dockerClient.NegotiateAPIVersion(context.Background())
|
||||
for _, c := range lg.getContainers() {
|
||||
if lg.sleepMethod == "stop" || lg.sleepMethod == "" {
|
||||
if err := dockerClient.ContainerStart(context.Background(), c.ID, types.ContainerStartOptions{}); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user