mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 11:03:34 +00:00
* feat: add support for ulimits in compose and container creation ([#221](https://github.com/ipaddicting/uncloud/issues/221)) * refactor: move Ulimits to ContainerResources and use map, also removed GEMINI.md.
This commit is contained in:
@@ -33,6 +33,7 @@ import (
|
||||
"github.com/docker/docker/client"
|
||||
"github.com/docker/docker/pkg/stdcopy"
|
||||
"github.com/docker/go-connections/nat"
|
||||
"github.com/docker/go-units"
|
||||
"github.com/google/go-containerregistry/pkg/authn"
|
||||
"github.com/google/go-containerregistry/pkg/name"
|
||||
"github.com/google/go-containerregistry/pkg/v1/remote"
|
||||
@@ -617,6 +618,7 @@ func (s *Server) CreateServiceContainer(
|
||||
Memory: spec.Container.Resources.Memory,
|
||||
MemoryReservation: spec.Container.Resources.MemoryReservation,
|
||||
DeviceRequests: spec.Container.Resources.DeviceReservations,
|
||||
Ulimits: toDockerUlimits(spec.Container.Resources.Ulimits),
|
||||
},
|
||||
// Restart service containers if they exit or a machine restarts unless they are explicitly stopped.
|
||||
// For one-off containers and batch jobs we plan to use a different service type/mode.
|
||||
@@ -877,6 +879,23 @@ func toDockerBindOptions(opts *api.BindOptions) *mount.BindOptions {
|
||||
return dockerOpts
|
||||
}
|
||||
|
||||
func toDockerUlimits(ulimits map[string]api.Ulimit) []*units.Ulimit {
|
||||
if len(ulimits) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
dockerUlimits := make([]*units.Ulimit, 0, len(ulimits))
|
||||
for name, u := range ulimits {
|
||||
dockerUlimits = append(dockerUlimits, &units.Ulimit{
|
||||
Name: name,
|
||||
Soft: u.Soft,
|
||||
Hard: u.Hard,
|
||||
})
|
||||
}
|
||||
|
||||
return dockerUlimits
|
||||
}
|
||||
|
||||
// verifyDockerVolumesExist checks if the Docker named volumes referenced in the mounts exist on the machine.
|
||||
func (s *Server) verifyDockerVolumesExist(ctx context.Context, mounts []mount.Mount) error {
|
||||
for _, m := range mounts {
|
||||
|
||||
Reference in New Issue
Block a user