diff --git a/agent/app/dto/container.go b/agent/app/dto/container.go
index 75566736b57d..aaa6caf25f28 100644
--- a/agent/app/dto/container.go
+++ b/agent/app/dto/container.go
@@ -272,13 +272,14 @@ type ComposeContainer struct {
Ports []string `json:"ports"`
}
type ComposeCreate struct {
- TaskID string `json:"taskID"`
- Name string `json:"name"`
- From string `json:"from" validate:"required,oneof=edit path template"`
- File string `json:"file"`
- Path string `json:"path"`
- Template uint `json:"template"`
- Env string `json:"env"`
+ TaskID string `json:"taskID"`
+ Name string `json:"name"`
+ From string `json:"from" validate:"required,oneof=edit path template"`
+ File string `json:"file"`
+ Path string `json:"path"`
+ Template uint `json:"template"`
+ Env string `json:"env"`
+ PullImage *bool `json:"pullImage,omitempty"`
}
type ComposeOperation struct {
Name string `json:"name" validate:"required"`
diff --git a/agent/app/service/container_compose.go b/agent/app/service/container_compose.go
index 7f80c287fbaa..f4f5cfa8b854 100644
--- a/agent/app/service/container_compose.go
+++ b/agent/app/service/container_compose.go
@@ -203,9 +203,13 @@ func (u *ContainerService) CreateCompose(req dto.ComposeCreate) error {
if err := newComposeEnv(req.Path, req.Env); err != nil {
return err
}
+ pullImages := true
+ if req.PullImage != nil {
+ pullImages = *req.PullImage
+ }
go func() {
taskItem.AddSubTask(i18n.GetMsgByKey("ComposeCreate"), func(t *task.Task) error {
- err := compose.UpWithTask(req.Path, t)
+ err := compose.UpWithTask(req.Path, t, pullImages)
t.LogWithStatus(i18n.GetMsgByKey("ComposeCreate"), err)
if err != nil {
_, _ = compose.Down(req.Path)
diff --git a/agent/utils/compose/compose.go b/agent/utils/compose/compose.go
index af3c43181076..6d13e6b23195 100644
--- a/agent/utils/compose/compose.go
+++ b/agent/utils/compose/compose.go
@@ -36,7 +36,10 @@ func Up(filePath string) (string, error) {
return cmd.NewCommandMgr(cmd.WithTimeout(20*time.Minute)).RunWithStdoutBashCf("%s %s up -d", global.CONF.DockerConfig.Command, loadFiles(filePath))
}
-func UpWithTask(filePath string, task *task.Task) error {
+func UpWithTask(filePath string, task *task.Task, pullImages bool) error {
+ if !pullImages {
+ return cmd.NewCommandMgr(cmd.WithTask(*task)).RunBashCf("%s %s up -d", global.CONF.DockerConfig.Command, loadFiles(filePath))
+ }
content, err := os.ReadFile(filePath)
if err != nil {
return err
diff --git a/frontend/src/api/interface/container.ts b/frontend/src/api/interface/container.ts
index b440d1fb0958..c0e4a5dcb24c 100644
--- a/frontend/src/api/interface/container.ts
+++ b/frontend/src/api/interface/container.ts
@@ -328,6 +328,8 @@ export namespace Container {
file: string;
path: string;
template: number;
+ env: string;
+ pullImage?: boolean;
}
export interface ComposeOperation {
name: string;
diff --git a/frontend/src/views/container/compose/index.vue b/frontend/src/views/container/compose/index.vue
index 5549fc227ea9..971b34d3991e 100644
--- a/frontend/src/views/container/compose/index.vue
+++ b/frontend/src/views/container/compose/index.vue
@@ -334,6 +334,11 @@
{{ $t('container.env') }}
+ {{ $t('commons.button.set') }}
+
+
+ {{ $t('app.pullImageHelper') }}
+
@@ -426,6 +431,7 @@ const form = reactive({
file: '',
template: null as number,
env: '',
+ pullImage: true,
});
const rules = reactive({
name: [Rules.requiredInput, Rules.composeName],
@@ -555,6 +561,7 @@ const onOpenDialog = async () => {
form.file = '';
form.template = null;
form.env = '';
+ form.pullImage = true;
loadPath();
loadTemplates();
};