mirror of
https://github.com/drone-plugins/drone-docker.git
synced 2026-06-26 16:03:24 +08:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 23887402c3 | |||
| e9bba4ffcf |
@@ -244,7 +244,7 @@ pipeline:
|
|||||||
identifier: go_build
|
identifier: go_build
|
||||||
spec:
|
spec:
|
||||||
connectorRef: Plugins_Docker_Hub_Connector
|
connectorRef: Plugins_Docker_Hub_Connector
|
||||||
image: golang:1.24.11
|
image: golang:1.23.0
|
||||||
shell: Sh
|
shell: Sh
|
||||||
command: |-
|
command: |-
|
||||||
# disable cgo
|
# disable cgo
|
||||||
@@ -332,7 +332,7 @@ pipeline:
|
|||||||
identifier: build_amd64ltsc2022
|
identifier: build_amd64ltsc2022
|
||||||
spec:
|
spec:
|
||||||
connectorRef: Plugins_Docker_Hub_Connector
|
connectorRef: Plugins_Docker_Hub_Connector
|
||||||
image: golang:1.24.11
|
image: golang:1.23.0
|
||||||
shell: Sh
|
shell: Sh
|
||||||
command: |-
|
command: |-
|
||||||
# disable cgo
|
# disable cgo
|
||||||
|
|||||||
@@ -112,6 +112,12 @@ func main() {
|
|||||||
Usage: "don't start the docker daemon",
|
Usage: "don't start the docker daemon",
|
||||||
EnvVar: "PLUGIN_DAEMON_OFF",
|
EnvVar: "PLUGIN_DAEMON_OFF",
|
||||||
},
|
},
|
||||||
|
cli.IntFlag{
|
||||||
|
Name: "daemon.retry-count",
|
||||||
|
Usage: "number of retry attempts to reach docker daemon",
|
||||||
|
Value: 15,
|
||||||
|
EnvVar: "PLUGIN_DAEMON_RETRY_COUNT",
|
||||||
|
},
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "dockerfile",
|
Name: "dockerfile",
|
||||||
Usage: "build dockerfile",
|
Usage: "build dockerfile",
|
||||||
@@ -419,6 +425,7 @@ func run(c *cli.Context) error {
|
|||||||
DNSSearch: c.StringSlice("daemon.dns-search"),
|
DNSSearch: c.StringSlice("daemon.dns-search"),
|
||||||
MTU: c.String("daemon.mtu"),
|
MTU: c.String("daemon.mtu"),
|
||||||
Experimental: c.Bool("daemon.experimental"),
|
Experimental: c.Bool("daemon.experimental"),
|
||||||
|
RetryCount: c.Int("daemon.retry-count"),
|
||||||
RegistryType: registryType,
|
RegistryType: registryType,
|
||||||
},
|
},
|
||||||
BaseImageRegistry: c.String("docker.baseimageregistry"),
|
BaseImageRegistry: c.String("docker.baseimageregistry"),
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ type (
|
|||||||
MTU string // Docker daemon mtu setting
|
MTU string // Docker daemon mtu setting
|
||||||
IPv6 bool // Docker daemon IPv6 networking
|
IPv6 bool // Docker daemon IPv6 networking
|
||||||
Experimental bool // Docker daemon enable experimental mode
|
Experimental bool // Docker daemon enable experimental mode
|
||||||
|
RetryCount int // Number of retry attempts to reach Docker daemon
|
||||||
RegistryType drone.RegistryType // Docker registry type
|
RegistryType drone.RegistryType // Docker registry type
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,14 +138,18 @@ func (p Plugin) Exec() error {
|
|||||||
|
|
||||||
// poll the docker daemon until it is started. This ensures the daemon is
|
// poll the docker daemon until it is started. This ensures the daemon is
|
||||||
// ready to accept connections before we proceed.
|
// ready to accept connections before we proceed.
|
||||||
|
maxRetries := p.Daemon.RetryCount
|
||||||
|
if maxRetries <= 0 {
|
||||||
|
maxRetries = 15 // default value
|
||||||
|
}
|
||||||
for i := 0; ; i++ {
|
for i := 0; ; i++ {
|
||||||
cmd := commandInfo()
|
cmd := commandInfo()
|
||||||
err := cmd.Run()
|
err := cmd.Run()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if i == 15 {
|
if i == maxRetries {
|
||||||
fmt.Println("Unable to reach Docker Daemon after 15 attempts.")
|
fmt.Printf("Unable to reach Docker Daemon after %d attempts.\n", maxRetries)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
time.Sleep(time.Second * 1)
|
time.Sleep(time.Second * 1)
|
||||||
|
|||||||
Reference in New Issue
Block a user