0

I am unable to pass arguments to a container entry point.

The error I am getting is:

Error: container create failed: time="2022-09-30T12:23:31Z" level=error msg="runc create failed: unable to start container process: exec: \"--base-currency=EUR\": executable file not found in $PATH"

How can I pass an arg with -- in it to the arg option in a PodSpec? I have tried using args directly, and as environment variables, both don't work. I have also tried arguments without "--" - still no joy.

The DeploymentConfig is:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: market-pricing
spec:
  replicas: 1
  selector:
    matchLabels:
      application: market-pricing
  template:
    metadata:
      labels:
        application: market-pricing
    spec:
      containers:
      - name: market-pricing
        image: quay.io/brbaker/market-pricing:v0.5.0
        args: ["$(BASE)","$(CURRENCIES)", "$(OUTPUT)"]
        imagePullPolicy: Always
        volumeMounts:
        - name: config
          mountPath: "/app/config"
          readOnly: true
        env:
          - name: BASE
            value: "--base-currency=EUR"
          - name: CURRENCIES
            value: "--currencies=AUD,NZD,USD"
          - name: OUTPUT
            value: "--dry-run"
      volumes:
      - name: config
        configMap:
          name: app-config  # Provide the name of the ConfigMap you want to mount.
          items:                  # An array of keys from the ConfigMap to create as files
          - key: "kafka.properties"
            path: "kafka.properties"
          - key: "app-config.properties"
            path: "app-config.properties"

The Dockerfile is:

FROM registry.redhat.io/ubi9:9.0.0-1640
WORKDIR /app
COPY bin/market-pricing-svc .
CMD ["/app/market-pricing-svc"]

The ConfigMap is:

apiVersion: v1
kind: ConfigMap
metadata:
  name: app-config
data:
  kafka.properties: |
    bootstrap.servers=fx-pricing-dev-kafka-bootstrap.kafka.svc.cluster.local:9092
    security.protocol=plaintext
    acks=all
  app-config.properties: |
    market-data-publisher=kafka-publisher
    market-data-source=ecb
    reader=time-reader
Bryon
  • 939
  • 13
  • 25
  • 1
    Change `CMD` to `ENTRYPOINT` in your dockerfile or alternatively add `command: ["/app/market-pricing-svc"]` to your manifest – jordanm Sep 30 '22 at 14:17
  • Possibly related (not a duplicate though) https://stackoverflow.com/questions/70928077/permission-denied-while-executing-script-entrypoint-sh-from-dockerfile-in-kubern/ – Blender Fox Oct 01 '22 at 07:49
  • Thanks. I got it working. It was a stupid mistake in the image itself. While debugging this I had commented out the CMD when I built an image v0.5.0. I had fixed it in a subsequent image v0.5.0 but not pushed it to quay.io. So Kubernetes just had the args and no command. That explains the strange error. – Bryon Oct 01 '22 at 22:48
  • @Bryon : Since your issue is resolved can you Post the solution you have for greater visibility of the community – Hemanth Kumar Dec 10 '22 at 06:31
  • @HemanthKumar In the Dockerfile above I had commented out this line: CMD ["/app/market-pricing-svc"]. I had rebuilt the image but not pushed it to the registry. So kubernetes was pulling the image that was missing the CMD. So there was no solution to this question as I had tied myself in knots testing different options. Everything above as is actually works. I.e. I made a stupid mistake. – Bryon Jan 10 '23 at 05:11

0 Answers0