Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/command/formatter/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ func (c *imageContext) CreatedAt() string {
}

func (c *imageContext) Size() string {
return units.HumanSizeWithPrecision(float64(c.i.Size), 3)
return units.HumanSize(float64(c.i.Size))
}

func (c *imageContext) Containers() string {
Expand Down
9 changes: 8 additions & 1 deletion opts/hosts.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,14 @@ func parseDockerDaemonHost(addr string) (string, error) {
proto, host, hasProto := strings.Cut(addr, "://")
if !hasProto && proto != "" {
host = proto
proto = "tcp"
// If the address looks like a filesystem path, default to "unix"
// rather than "tcp" to avoid confusing errors when the user sets
// DOCKER_HOST=/path/to/sock without a unix:// prefix.
if strings.HasPrefix(host, "/") || strings.HasPrefix(host, "./") {
proto = "unix"
} else {
proto = "tcp"
}
}

switch proto {
Expand Down
2 changes: 2 additions & 0 deletions opts/hosts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ func TestParseDockerDaemonHost(t *testing.T) {
"unix://": "unix://" + defaultUnixSocket,
"fd://": "fd://",
"fd://something": "fd://something",
"/var/run/docker.sock": "unix:///var/run/docker.sock",
"./run/docker.sock": "unix://run/docker.sock",
"localhost:": "tcp://localhost:2375",
"localhost:5555": "tcp://localhost:5555",
"localhost:5555/path": "tcp://localhost:5555/path",
Expand Down