mirror of
https://github.com/acepanel/panel.git
synced 2026-02-04 01:57:19 +08:00
fix: 兼容一些没有指定命令和入口点的镜像
This commit is contained in:
@@ -100,6 +100,19 @@ func (r *containerRepo) Create(req *request.ContainerCreate) (string, error) {
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
// 获取镜像信息
|
||||
image, err := apiClient.ImageInspect(ctx, req.Image)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to inspect image: %v", err)
|
||||
}
|
||||
// 兼容一些没有指定命令和入口点的镜像
|
||||
if len(req.Command) == 0 && len(image.Config.Cmd) > 0 {
|
||||
req.Command = image.Config.Cmd
|
||||
}
|
||||
if len(req.Entrypoint) == 0 && len(image.Config.Entrypoint) > 0 {
|
||||
req.Entrypoint = image.Config.Entrypoint
|
||||
}
|
||||
|
||||
// 构建容器配置
|
||||
config := &container.Config{
|
||||
Image: req.Image,
|
||||
@@ -136,10 +149,10 @@ func (r *containerRepo) Create(req *request.ContainerCreate) (string, error) {
|
||||
portMap := make(network.PortMap)
|
||||
for _, port := range req.Ports {
|
||||
if port.ContainerStart-port.ContainerEnd != port.HostStart-port.HostEnd {
|
||||
return "", fmt.Errorf("容器端口和主机端口数量不匹配(容器: %d 主机: %d)", port.ContainerStart-port.ContainerEnd, port.HostStart-port.HostEnd)
|
||||
return "", fmt.Errorf("container port and host port count do not match (container: %d host: %d)", port.ContainerStart-port.ContainerEnd, port.HostStart-port.HostEnd)
|
||||
}
|
||||
if port.ContainerStart > port.ContainerEnd || port.HostStart > port.HostEnd || port.ContainerStart < 1 || port.HostStart < 1 {
|
||||
return "", fmt.Errorf("端口范围不正确")
|
||||
return "", fmt.Errorf("port range is invalid")
|
||||
}
|
||||
|
||||
count := uint(0)
|
||||
|
||||
Reference in New Issue
Block a user