You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

升级Node.js与Angular后前端Pod启动失败:OCI无命令指定错误

问题:升级Node.js和Angular后前端Pod启动失败,报错"no command specified"

升级Node.js和Angular到新版本后,前端Pod无法启动,ArgoCD创建容器时出现以下错误:

failed to apply OCI options: no command specified

这类问题通常通过修复Dockerfile解决,但未能定位到问题所在,以下是相关文件内容:

Dockerfile内容

# Stage 0, "build-stage", based on Node.js, to build and compile Angular
FROM node:22.5.1-alpine as build-stage
# Proxy Settings
ENV http_proxy ENTERPRISEPROXY
ENV https_proxy ENTERPRISEPROXY
ENV NODE_OPTIONS='--max_old_space_size=4096'
ENV KEYCLOAK_URL='Keine Keycloak URL'
ENV STAGE='Keine Stage'
ENV BACKEND_URL='Keine BACKEND_URL'
WORKDIR /app
COPY package*.json /app/
RUN npm install
COPY ./ /app/
ARG configuration=production
RUN npm run build -- --output-path=./dist/APPNAME--configuration $configuration
# Stage 1, based on Nginx, to have only the compiled app, ready for production with Nginx
FROM nginx:1.27.0
COPY --from=build-stage /app/dist/APPNAME/browser/ /usr/share/nginx/html
COPY --from=build-stage /app/nginx.conf /etc/nginx/conf.d/default.conf
RUN chgrp -R root /var/cache/nginx /var/run /var/log/nginx && \
    chmod -R 777 /var/cache/nginx /var/run /var/log/nginx /usr/share/nginx/html/assets/json && \
    chown -R 101 /usr/share/nginx/html

EXPOSE 4200
## startup.sh script is launched at container run
ADD /startup.sh /startup.sh
RUN ["chmod", "+x", "/startup.sh"]

CMD /startup.sh 

startup.sh内容

echo "Starting application..."
echo "KEYCLOAK_URL = ${KEYCLOAK_URL}"
envsubst < "/usr/share/nginx/html/assets/json/runtime.json" > "/usr/share/nginx/html/assets/json/env.json"

cat "/usr/share/nginx/html/assets/json/env.json"
nginx -g 'daemon off;'

Pod清单

apiVersion: v1
kind: Pod
metadata:
  annotations:
    cni.projectcalico.org/containerID: 1d42c91198100a64a958f82b04b573bdb648d2955967e941c090f6af38706b2e
    cni.projectcalico.org/podIP: 10.4.176.212/32
    cni.projectcalico.org/podIPs: 10.4.176.212/32
    kubectl.kubernetes.io/restartedAt: '2024-07-30T12:52:29Z'
    kubernetes.io/limit-ranger: >-
      LimitRanger plugin set: ephemeral-storage request for container
      APPNAME-frontend; ephemeral-storage limit for container APPNAME-frontend
  creationTimestamp: '2024-08-28T12:32:42Z'
  generateName: com-APPNAME-f-884f975db-
  labels:
    app: com-APPNAME-f
    pod-template-hash: 884f975db
  name: com-APPNAME-f-884f975db-tsgd7
  namespace: NAMESPACE-staging
  ownerReferences:
    - apiVersion: apps/v1
      blockOwnerDeletion: true
      controller: true
      kind: ReplicaSet
      name: com-APPNAME-f-884f975db
      uid: f68cdc3c-ec68-453b-9664-1ecc0bb9f3f5
  resourceVersion: '4312982382'
  uid: cd8a146a-70ac-4ad7-a03d-e9574356fdfe
spec:
  containers:
    - env:
        - name: BACKEND_URL
          value: 'REDACTED'
        - name: KEYCLOAK_URL
          value: 'REDACTED'
        - name: STAGE
          value: ost
      image: 'REDACTED/APPNAME:v3.7.3'
      imagePullPolicy: Always
      livenessProbe:
        failureThreshold: 3
        httpGet:
          path: /
          port: 4200
          scheme: HTTP
        initialDelaySeconds: 10
        periodSeconds: 10
        successThreshold: 1
        timeoutSeconds: 2
      name: APPNAME-frontend
      ports:
        - containerPort: 4200
          protocol: TCP
      readinessProbe:
        failureThreshold: 3
        httpGet:
          path: /
          port: 4200
          scheme: HTTP
        initialDelaySeconds: 10
        periodSeconds: 2
        successThreshold: 1
        timeoutSeconds: 2
      resources:
        limits:
          cpu: '1'
          ephemeral-storage: 300Mi
          memory: 512Mi
        requests:
          cpu: 100m
          ephemeral-storage: 300Mi
          memory: 128Mi
      terminationMessagePath: /dev/termination-log
      terminationMessagePolicy: File
      volumeMounts:
        - mountPath: /var/run/secrets/kubernetes.io/serviceaccount
          name: kube-api-access-pg982
          readOnly: true
  dnsPolicy: ClusterFirst
  enableServiceLinks: true
  nodeName: rxcmpk8s24.REDACTED
  preemptionPolicy: PreemptLowerPriority
  priority: 1
  priorityClassName: low
  restartPolicy: Always
  schedulerName: default-scheduler
  securityContext:
    fsGroup: 1000
    runAsUser: 101
  serviceAccount: default
  serviceAccountName: default
  terminationGracePeriodSeconds: 30
  tolerations:
    - effect: NoExecute
      key: node.kubernetes.io/not-ready
      operator: Exists
      tolerationSeconds: 300
    - effect: NoExecute
      key: node.kubernetes.io/unreachable
      operator: Exists
      tolerationSeconds: 300
  volumes:
    - name: kube-api-access-pg982
      projected:
        defaultMode: 420
        sources:
          - serviceAccountToken:
              expirationSeconds: 3607
              path: token
          - configMap:
              items:
                - key: ca.crt
                  path: ca.crt
              name: kube-root-ca.crt
          - downwardAPI:
              items:
                - fieldRef:
                    apiVersion: v1
                    fieldPath: metadata.namespace
                  path: namespace
status:
  conditions:
    - lastProbeTime: null
      lastTransitionTime: '2024-08-28T12:32:42Z'
      status: 'True'
      type: Initialized
    - lastProbeTime: null
      lastTransitionTime: '2024-08-28T12:32:42Z'
      message: 'containers with unready status: [APPNAME-frontend]'
      reason: ContainersNotReady
      status: 'False'
      type: Ready
    - lastProbeTime: null
      lastTransitionTime: '2024-08-28T12:32:42Z'
      message: 'containers with unready status: [APPNAME-frontend]'
      reason: ContainersNotReady
      status: 'False'
      type: ContainersReady
    - lastProbeTime: null
      lastTransitionTime: '2024-08-28T12:32:42Z'
      status: 'True'
      type: PodScheduled
  containerStatuses:
    - image: 'REDACTED/APPNAMEfrontend:v3.7.3'
      imageID: ''
      lastState: {}
      name: APPNAME-frontend
      ready: false
      restartCount: 0
      started: false
      state:
        waiting:
          message: >-
            failed to generate container
            "92ba9931053ad88e033bb8ae74fc683b75b7d2c6ebc94915d3f5910496b83149"
            spec: failed to apply OCI options: no command specified
          reason: CreateContainerError
  hostIP: 172.31.102.102
  phase: Pending
  podIP: 10.4.176.212
  podIPs:
    - ip: 10.4.176.212
  qosClass: Burstable
  startTime: '2024-08-28T12:32:42Z'

修复方案

  • 修改Dockerfile的CMD格式:将CMD /startup.sh改为exec格式,避免OCI runtime解析问题:
    CMD ["/startup.sh"]
    
  • 确保脚本权限与归属:在Dockerfile中添加指令,确保运行用户拥有脚本权限:
    RUN chown 101:101 /startup.sh
    
  • 验证构建后的镜像:构建完成后,通过docker run --rm <image-name> /startup.sh测试脚本是否能正常执行,确认没有权限或路径问题。

内容的提问来源于stack exchange,提问作者sav

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.19 04:45:54