/root/go/pkg/mod/github.com/theupdateframework/[email protected]/tuf/data/keys.go:15:2: module github.com/agl/ed25519@latest found (v0.0.0-20200225211852-fd4d107ace12), but does not contain package github.com/agl/ed25519
/root/go/pkg/mod/github.com/docker/[email protected]/cli/command/service/opts.go:18:2: module github.com/docker/swarmkit@latest found (v1.12.0), but does not contain package github.com/docker/swarmkit/api/defaults
/root/go/pkg/mod/github.com/docker/[email protected]/cli/command/service/generic_resource_opts.go:11:2: module github.com/docker/swarmkit@latest found (v1.12.0), but does not contain package github.com/docker/swarmkit/api/genericresource
/root/go/pkg/mod/github.com/docker/[email protected]/manager/raftpicker/raftpicker.go:8:2: module google.golang.org/grpc@latest found (v1.29.1), but does not contain package google.golang.org/grpc/transport
package main
import (
"context"
"github.com/docker/cli/cli/compose/convert"
"github.com/docker/cli/cli/compose/loader"
cli_types "github.com/docker/cli/cli/compose/types"
"github.com/docker/docker/client"
"log"
)
func main() {
config, err := loader.Load(cli_types.ConfigDetails{
Version: "3.0",
WorkingDir: ".",
ConfigFiles: []cli_types.ConfigFile{
{
Config: map[string]interface{}{
"mysql": map[string]interface{}{
"image": "mysql",
},
},
},
},
})
ctx := context.Background()
cli, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
if err != nil {
panic(err)
}
services, err := convert.Services(convert.NewNamespace("test"), config, cli)
if err != nil {
log.Fatal(err)
}
log.Printf("%+v %+v", services, ctx)
}
Updating all packages (cli, engine, swarmkit) to the latest commit via go mod solved the issue. You should really switch to go mod.
@loeffel-io which version did you update to solve this? I'm assuming that v1.13.1 is "latest" per docs but v20.10.0+incompatible has more recent commits.
v1.13.1 is a couple of years old (and should not be used), but pkg.go.dev expects SemVer (or more factually; SemVer _formatted_) tags, and ignores other ones. Docker does binary releases using CalVer format, which are not shown as "latest" version on pkg.go.dev
Thanks and I appreciate the explanation about versioning! I'll make sure I use v20.10.0 and later. I also realized I could have simply checked the latest version available on Releases.
Most helpful comment
Updating all packages (cli, engine, swarmkit) to the latest commit via go mod solved the issue. You should really switch to go mod.