Skip to content

Commit 1b50cbf

Browse files
committed
update docker
1 parent 891c51a commit 1b50cbf

File tree

7 files changed

+31
-23
lines changed

7 files changed

+31
-23
lines changed

cmd/diagnostics.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"github.com/docker/docker/pkg/parsers/operatingsystem"
2424
"github.com/goccy/go-json"
2525
"github.com/spf13/cobra"
26+
dockerSystem "github.com/docker/docker/api/types/system" // Alias the correct system package
2627

2728
"github.com/pelican-dev/wings/config"
2829
"github.com/pelican-dev/wings/environment"
@@ -208,18 +209,18 @@ func diagnosticsCmdRun(*cobra.Command, []string) {
208209
}
209210
}
210211

211-
func getDockerInfo() (types.Version, types.Info, error) {
212+
func getDockerInfo() (types.Version, dockerSystem.Info, error) {
212213
client, err := environment.Docker()
213214
if err != nil {
214-
return types.Version{}, types.Info{}, err
215+
return types.Version{}, dockerSystem.Info{}, err
215216
}
216217
dockerVersion, err := client.ServerVersion(context.Background())
217218
if err != nil {
218-
return types.Version{}, types.Info{}, err
219+
return types.Version{}, dockerSystem.Info{}, err
219220
}
220221
dockerInfo, err := client.Info(context.Background())
221222
if err != nil {
222-
return types.Version{}, types.Info{}, err
223+
return types.Version{}, dockerSystem.Info{}, err
223224
}
224225
return dockerVersion, dockerInfo, nil
225226
}

environment/docker.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,10 @@ func ConfigureDocker(ctx context.Context) error {
7272
// Creates a new network on the machine if one does not exist already.
7373
func createDockerNetwork(ctx context.Context, cli *client.Client) error {
7474
nw := config.Get().Docker.Network
75-
_, err := cli.NetworkCreate(ctx, nw.Name, types.NetworkCreate{
75+
enableIPv6 := true // define a bool variable
76+
_, err := cli.NetworkCreate(ctx, nw.Name, network.CreateOptions{
7677
Driver: nw.Driver,
77-
EnableIPv6: true,
78+
EnableIPv6: &enableIPv6,
7879
Internal: nw.IsInternal,
7980
IPAM: &network.IPAM{
8081
Config: []network.IPAMConfig{{

environment/docker/container.go

+8-6
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"github.com/docker/docker/api/types/container"
1717
"github.com/docker/docker/api/types/mount"
1818
"github.com/docker/docker/client"
19+
dockerImages "github.com/docker/docker/api/types/image" // Alias the correct images package
1920

2021
"github.com/pelican-dev/wings/config"
2122
"github.com/pelican-dev/wings/environment"
@@ -49,7 +50,7 @@ func (e *Environment) Attach(ctx context.Context) error {
4950
return nil
5051
}
5152

52-
opts := types.ContainerAttachOptions{
53+
opts := container.AttachOptions{
5354
Stdin: true,
5455
Stdout: true,
5556
Stderr: true,
@@ -195,6 +196,7 @@ func (e *Environment) Create() error {
195196

196197
networkMode := container.NetworkMode(cfg.Docker.Network.Mode)
197198
if a.ForceOutgoingIP {
199+
enableIPv6 := false // define a bool variable
198200
e.log().Debug("environment/docker: forcing outgoing IP address")
199201
networkName := "ip-" + strings.ReplaceAll(strings.ReplaceAll(a.DefaultMapping.Ip, ".", "-"), ":", "-")
200202
networkMode = container.NetworkMode(networkName)
@@ -206,7 +208,7 @@ func (e *Environment) Create() error {
206208

207209
if _, err := e.client.NetworkCreate(ctx, networkName, types.NetworkCreate{
208210
Driver: "bridge",
209-
EnableIPv6: false,
211+
EnableIPv6: &enableIPv6,
210212
Internal: false,
211213
Attachable: false,
212214
Ingress: false,
@@ -270,7 +272,7 @@ func (e *Environment) Destroy() error {
270272
// We set it to stopping than offline to prevent crash detection from being triggered.
271273
e.SetState(environment.ProcessStoppingState)
272274

273-
err := e.client.ContainerRemove(context.Background(), e.Id, types.ContainerRemoveOptions{
275+
err := e.client.ContainerRemove(context.Background(), e.Id, container.RemoveOptions{
274276
RemoveVolumes: true,
275277
RemoveLinks: false,
276278
Force: true,
@@ -316,7 +318,7 @@ func (e *Environment) SendCommand(c string) error {
316318
// is running or not, it will simply try to read the last X bytes of the file
317319
// and return them.
318320
func (e *Environment) Readlog(lines int) ([]string, error) {
319-
r, err := e.client.ContainerLogs(context.Background(), e.Id, types.ContainerLogsOptions{
321+
r, err := e.client.ContainerLogs(context.Background(), e.Id, container.LogsOptions{
320322
ShowStdout: true,
321323
ShowStderr: true,
322324
Tail: strconv.Itoa(lines),
@@ -371,7 +373,7 @@ func (e *Environment) ensureImageExists(image string) error {
371373
}
372374

373375
// Get the ImagePullOptions.
374-
imagePullOptions := types.ImagePullOptions{All: false}
376+
imagePullOptions := dockerImages.PullOptions{All: false}
375377
if registryAuth != nil {
376378
b64, err := registryAuth.Base64()
377379
if err != nil {
@@ -384,7 +386,7 @@ func (e *Environment) ensureImageExists(image string) error {
384386

385387
out, err := e.client.ImagePull(ctx, image, imagePullOptions)
386388
if err != nil {
387-
images, ierr := e.client.ImageList(ctx, types.ImageListOptions{})
389+
images, ierr := e.client.ImageList(ctx, dockerImages.ListOptions{})
388390
if ierr != nil {
389391
// Well damn, something has gone really wrong here, just go ahead and abort there
390392
// isn't much anything we can do to try and self-recover from this.

environment/docker/power.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99

1010
"emperror.dev/errors"
1111
"github.com/apex/log"
12-
"github.com/docker/docker/api/types"
1312
"github.com/docker/docker/api/types/container"
1413
"github.com/docker/docker/client"
1514

@@ -27,7 +26,7 @@ import (
2726
// is running does not result in the server becoming un-bootable.
2827
func (e *Environment) OnBeforeStart(ctx context.Context) error {
2928
// Always destroy and re-create the server container to ensure that synced data from the Panel is used.
30-
if err := e.client.ContainerRemove(ctx, e.Id, types.ContainerRemoveOptions{RemoveVolumes: true}); err != nil {
29+
if err := e.client.ContainerRemove(ctx, e.Id, container.RemoveOptions{RemoveVolumes: true}); err != nil {
3130
if !client.IsErrNotFound(err) {
3231
return errors.WrapIf(err, "environment/docker: failed to remove container during pre-boot")
3332
}
@@ -120,7 +119,7 @@ func (e *Environment) Start(ctx context.Context) error {
120119
return errors.WrapIf(err, "environment/docker: failed to attach to container")
121120
}
122121

123-
if err := e.client.ContainerStart(actx, e.Id, types.ContainerStartOptions{}); err != nil {
122+
if err := e.client.ContainerStart(actx, e.Id, container.StartOptions{}); err != nil {
124123
return errors.WrapIf(err, "environment/docker: failed to start container")
125124
}
126125

go.mod

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ require (
1414
github.com/buger/jsonparser v1.1.1
1515
github.com/cenkalti/backoff/v4 v4.3.0
1616
github.com/creasty/defaults v1.7.0
17-
github.com/docker/docker v25.0.5+incompatible
17+
github.com/docker/docker v27.0.3+incompatible
1818
github.com/docker/go-connections v0.5.0
1919
github.com/fatih/color v1.17.0
2020
github.com/franela/goblin v0.0.0-20211003143422-0a4f594942bf
@@ -95,6 +95,7 @@ require (
9595
github.com/magefile/mage v1.15.0 // indirect
9696
github.com/mattn/go-isatty v0.0.20 // indirect
9797
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
98+
github.com/moby/docker-image-spec v1.3.1 // indirect
9899
github.com/moby/term v0.0.0-20220808134915-39b0c02b01ae // indirect
99100
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
100101
github.com/modern-go/reflect2 v1.0.2 // indirect

go.sum

+4
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5Qvfr
8888
github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E=
8989
github.com/docker/docker v25.0.5+incompatible h1:UmQydMduGkrD5nQde1mecF/YnSbTOaPeFIeP5C4W+DE=
9090
github.com/docker/docker v25.0.5+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
91+
github.com/docker/docker v27.0.3+incompatible h1:aBGI9TeQ4MPlhquTQKq9XbK79rKFVwXNUAYz9aXyEBE=
92+
github.com/docker/docker v27.0.3+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
9193
github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c=
9294
github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc=
9395
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
@@ -273,6 +275,8 @@ github.com/mholt/archiver/v4 v4.0.0-alpha.8 h1:tRGQuDVPh66WCOelqe6LIGh0gwmfwxUrS
273275
github.com/mholt/archiver/v4 v4.0.0-alpha.8/go.mod h1:5f7FUYGXdJWUjESffJaYR4R60VhnHxb2X3T1teMyv5A=
274276
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db h1:62I3jR2EmQ4l5rM/4FEfDWcRD+abF5XlKShorW5LRoQ=
275277
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db/go.mod h1:l0dey0ia/Uv7NcFFVbCLtqEBQbrT4OCwCSKTEv6enCw=
278+
github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0=
279+
github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo=
276280
github.com/moby/term v0.0.0-20220808134915-39b0c02b01ae h1:O4SWKdcHVCvYqyDV+9CJA1fcDN2L11Bule0iFy3YlAI=
277281
github.com/moby/term v0.0.0-20220808134915-39b0c02b01ae/go.mod h1:E2VnQOmVuvZB6UYnnDB0qG5Nq/1tD9acaOpo6xmt0Kw=
278282
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=

server/install.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ import (
1313

1414
"emperror.dev/errors"
1515
"github.com/apex/log"
16-
"github.com/docker/docker/api/types"
1716
"github.com/docker/docker/api/types/container"
1817
"github.com/docker/docker/api/types/mount"
1918
"github.com/docker/docker/client"
19+
dockerImages "github.com/docker/docker/api/types/image" // Alias the correct images package
2020

2121
"github.com/pelican-dev/wings/config"
2222
"github.com/pelican-dev/wings/environment"
@@ -161,7 +161,7 @@ func (s *Server) SetRestoring(state bool) {
161161

162162
// RemoveContainer removes the installation container for the server.
163163
func (ip *InstallationProcess) RemoveContainer() error {
164-
err := ip.client.ContainerRemove(ip.Server.Context(), ip.Server.ID()+"_installer", types.ContainerRemoveOptions{
164+
err := ip.client.ContainerRemove(ip.Server.Context(), ip.Server.ID()+"_installer", container.RemoveOptions{
165165
RemoveVolumes: true,
166166
Force: true,
167167
})
@@ -247,7 +247,7 @@ func (ip *InstallationProcess) pullInstallationImage() error {
247247
}
248248

249249
// Get the ImagePullOptions.
250-
imagePullOptions := types.ImagePullOptions{All: false}
250+
imagePullOptions := dockerImages.PullOptions{All: false}
251251
if registryAuth != nil {
252252
b64, err := registryAuth.Base64()
253253
if err != nil {
@@ -260,7 +260,7 @@ func (ip *InstallationProcess) pullInstallationImage() error {
260260

261261
r, err := ip.client.ImagePull(ip.Server.Context(), ip.Script.ContainerImage, imagePullOptions)
262262
if err != nil {
263-
images, ierr := ip.client.ImageList(ip.Server.Context(), types.ImageListOptions{})
263+
images, ierr := ip.client.ImageList(ip.Server.Context(), dockerImages.ListOptions{})
264264
if ierr != nil {
265265
// Well damn, something has gone really wrong here, just go ahead and abort there
266266
// isn't much anything we can do to try and self-recover from this.
@@ -332,7 +332,7 @@ func (ip *InstallationProcess) AfterExecute(containerId string) error {
332332
defer ip.RemoveContainer()
333333

334334
ip.Server.Log().WithField("container_id", containerId).Debug("pulling installation logs for server")
335-
reader, err := ip.client.ContainerLogs(ip.Server.Context(), containerId, types.ContainerLogsOptions{
335+
reader, err := ip.client.ContainerLogs(ip.Server.Context(), containerId, container.LogsOptions{
336336
ShowStdout: true,
337337
ShowStderr: true,
338338
Follow: false,
@@ -463,7 +463,7 @@ func (ip *InstallationProcess) Execute() (string, error) {
463463
}
464464

465465
ip.Server.Log().WithField("container_id", r.ID).Info("running installation script for server in container")
466-
if err := ip.client.ContainerStart(ctx, r.ID, types.ContainerStartOptions{}); err != nil {
466+
if err := ip.client.ContainerStart(ctx, r.ID, container.StartOptions{}); err != nil {
467467
return "", err
468468
}
469469

@@ -498,7 +498,7 @@ func (ip *InstallationProcess) Execute() (string, error) {
498498
// the server configuration directory, as well as to a websocket listener so
499499
// that the process can be viewed in the panel by administrators.
500500
func (ip *InstallationProcess) StreamOutput(ctx context.Context, id string) error {
501-
opts := types.ContainerLogsOptions{ShowStdout: true, ShowStderr: true, Follow: true}
501+
opts := container.LogsOptions{ShowStdout: true, ShowStderr: true, Follow: true}
502502
reader, err := ip.client.ContainerLogs(ctx, id, opts)
503503
if err != nil {
504504
return err

0 commit comments

Comments
 (0)