Should recognize inexplicit defined `default` network
hiimdoublej-swag opened this issue · comments
My compose file is like this, which is not considered valid by this package yet.
version: "3"
services:
test:
build: .
networks:
- default
The default
network here is technically valid, even though it's not defined in a networks
section for the compose file , since
- It is the default network created for the user when using
docker compose
. - Running
docker-compose up
on the same file doesn't show an error, proving that it is a valid compose file.
I think this is a bug and I've scrambled together a sufficient test, but due to my unfamiliarity with golang I'm not sure where/how would I implement a fix.
Is it as straightforward as just ensure there's a default
network available in loader/validate.go:checkConsistency
?
Corresponding test:
func TestValidateInexplicitDefaultNetwork(t *testing.T) {
project := &types.Project{
Services: types.Services([]types.ServiceConfig{
{
Name: "myservice",
Image: "scratch",
Networks: map[string]*types.ServiceNetworkConfig{
"default": {},
},
},
}),
}
err := checkConsistency(project)
assert.NilError(t, err)
}
which is not considered valid by this package yet
what makes you think so ?
Docker Compose is the reference implementation for the Compose Specification and relies on compose-go, and as you noticed docker compose up
has no issue with such a compose file. You can use docker compose config
to confirm the implicit default
network is well set.
Commented on docker/buildx#906