<p>I am trying to run a shell script at the start of a docker container running on Google Cloud Containers using Kubernetes. The structure of my app directory is something like this. I'd like to run prod_start.sh script at the start of the container (I don't want to put it as part of the Dockerfile though). The current setup fails to start the container with <code>Command not found file ./prod_start.sh does not exist</code>. Any idea how to fix this?</p>

<pre><code>app/
  ...
  Dockerfile
  prod_start.sh
  web-controller.yaml
  Gemfile
  ...
</code></pre>

<p>Dockerfile</p>

<pre><code>FROM ruby
RUN mkdir /backend
WORKDIR /backend
ADD Gemfile /backend/Gemfile
ADD Gemfile.lock /backend/Gemfile.lock
RUN bundle install
</code></pre>

<p>web-controller.yaml</p>

<pre><code>apiVersion: v1
kind: ReplicationController
metadata:
  name: backend
  labels:
    app: myapp
    tier: backend
spec:
  replicas: 1
  selector:
    app: myapp
    tier: backend
  template:
    metadata:
      labels:
        app: myapp
        tier: backend
    spec:
      volumes:
      - name: secrets
        secret:
          secretName: secrets
      containers:
      - name: my-backend
        command: ['./prod_start.sh']
        image: gcr.io/myapp-id/myapp-backend:v1
        volumeMounts:
        - name: secrets
          mountPath: /etc/secrets
          readOnly: true
        resources:
          requests:
            cpu: 100m
            memory: 100Mi
        ports:
        - containerPort: 80
          name: http-server
</code></pre>

<p>After a lot of experimentations I believe adding the script to the <code>Dockerfile</code>:</p>

<pre><code>ADD prod_start.sh /backend/prod_start.sh
</code></pre>

<p>And then calling the command like this in the <code>yaml</code> controller file:</p>

<pre><code>command: ['/bin/sh', './prod_start.sh']
</code></pre>

<p>Fixed it.</p>
