<p>I have multiple Testcafe scripts (<code>script1.js</code>, <code>script2.js</code>) that are working fine. I have Dockerized this code into a Dockerfile and it works fine when I run the Docker Image. Next, I want to invoke this Docker Image as a CronJob in Kubernetes. Given below is my <code>manifest.yaml</code> file.</p>
<pre><code>apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: application-automation-framework
  namespace: development
  labels:
    team: development
spec:
  schedule: &quot;*/1 * * * *&quot;
  jobTemplate:
    metadata:
      labels:
        team: development
    spec:
      ttlSecondsAfterFinished: 120
      backoffLimit: 3
      template:
        metadata:
          labels:
            team: development
        spec:
          containers:
            - name: script1-job
              image: testcafe-minikube
              imagePullPolicy: Never
              args: [&quot;chromium:headless&quot;, &quot;script1.js&quot;]
            - name: script2-job
              image: testcafe-minikube
              imagePullPolicy: Never
              args: [ &quot;chromium:headless&quot;, &quot;script2.js&quot;]
          restartPolicy: OnFailure
</code></pre>
<p>As seen above, this manifest has two containers running. When I apply this manifest to Kubernetes, the first container (<code>script1-job</code>), runs well. But the second container (<code>script2-job</code>) gives me the following error.</p>
<pre><code>ERROR The specified 1337 port is already in use by another program.
</code></pre>
<p>If I run this with one container, it works perfectly. I also tried changing the args of the containers to the following.</p>
<pre><code>args: [&quot;chromium:headless&quot;, &quot;script1.js&quot;, &quot;--ports 12345,12346&quot;]
args: [&quot;chromium:headless&quot;, &quot;script2.js&quot;, &quot;--ports 1234,1235&quot;]
</code></pre>
<p>Still, I get the same error saying 1337 port already in use. (I wonder whether the <code>--ports</code> argument is working at all in Docker).</p>
<p>This is my <code>Dockerfile</code> for reference.</p>
<pre><code>FROM testcafe/testcafe
COPY . ./
USER root
RUN npm install
</code></pre>
<p>Could someone please help me with this? I want to run multiple containers as Cronjobs in Kubernetes, where I can run multiple Testcafe scripts in each job invocation?</p>

<p>adding the containerPort configuration to your kubernetes resource should do the trick.</p>
<p>for example:</p>
<pre><code>    spec:
      containers:
        - name: script1-job
          image: testcafe-minikube
          imagePullPolicy: Never
          args: [&quot;chromium:headless&quot;, &quot;script1.js&quot;, &quot;--ports 12345,12346&quot;]
          ports: 
          - containerPort: 12346
</code></pre>
