mirror of
https://github.com/moby/moby.git
synced 2025-12-13 22:02:25 +03:00
check tag's validity before building.
When user passes an invalid tag to `docker build` (i.e. `docker build -t abcd:A0123456789B0123456789C0123456789 .`), check the tag first and terminate-early so user can specify the tag again Docker-DCO-1.1-Signed-off-by: Daniel, Dao Quang Minh <dqminh89@gmail.com> (github: dqminh)
This commit is contained in:
@@ -26,6 +26,7 @@ import (
|
||||
"github.com/docker/docker/archive"
|
||||
"github.com/docker/docker/dockerversion"
|
||||
"github.com/docker/docker/engine"
|
||||
"github.com/docker/docker/graph"
|
||||
"github.com/docker/docker/nat"
|
||||
"github.com/docker/docker/opts"
|
||||
"github.com/docker/docker/pkg/log"
|
||||
@@ -174,10 +175,15 @@ func (cli *DockerCli) CmdBuild(args ...string) error {
|
||||
|
||||
//Check if the given image name can be resolved
|
||||
if *tag != "" {
|
||||
repository, _ := parsers.ParseRepositoryTag(*tag)
|
||||
repository, tag := parsers.ParseRepositoryTag(*tag)
|
||||
if _, _, err := registry.ResolveRepositoryName(repository); err != nil {
|
||||
return err
|
||||
}
|
||||
if len(tag) > 0 {
|
||||
if err := graph.ValidateTagName(tag); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
v.Set("t", *tag)
|
||||
|
||||
Reference in New Issue
Block a user