Docker - Unable to start Webpack Dev Server on Kubernetes Cluster

12/27/2018

I am trying to start Webpack Dev Server in a Rails app on a Digital Ocean Kubernetes Cluster. I can't figure out the correct command. The app works in Docker locally.

I keep getting errors like this:

Error: failed to start container "exactpos-webpack": Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"bin/bash\": stat bin/bash: no such file or directory": unknown Back-off restarting failed container

Here is the code from my docker-compose.yml file:

webpack_dev_server: build: .
command: ./bin/webpack-dev-server 
ports:
- 3035:3035 
volumes:
- .:/usr/src/app
- gem_cache:/gems 
env_file:
- .env/development/web
- .env/development/database environment:
- WEBPACKER_DEV_SERVER_HOST=0.0.0.0

Here is my kubectl deployment yaml file:

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: exactpos-webpack
spec:
  replicas: 1
  minReadySeconds: 150
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1  
  selector:
    matchLabels: 
      app: exactpos-webpack
      tier: webpack
  template:
    metadata:
      name: exactpos-webppack
      labels:
        app: exactpos-webpack
        tier: webpack
    spec:
      imagePullSecrets:
        - name: dockerhub-cred
      containers:             
        - name: exactpos-webpack
          image: index.docker.io/markhorrocks/exactpos_webpacker_dev_server:prod
          command: ["bin/bash","-c", "./bin/webpack_dev_server"]
          imagePullPolicy: Always
          ports:
            - containerPort: 3500       
          readinessProbe:
            tcpSocket:
              port: 3500
            initialDelaySeconds: 150
            timeoutSeconds: 5
            periodSeconds: 5
            failureThreshold: 10
          livenessProbe:
            tcpSocket:
              port: 3500
            initialDelaySeconds: 120
            timeoutSeconds: 5
            periodSeconds: 5
            failureThreshold: 10
          env:
          - name: RAILS_LOG_TO_STDOUT
            value: "true"
          - name: RAILS_SERVE_STATIC_FILES
            value: "true"
          - name: DATABASE_NAME
            value: "exactpos_production"
          - name: DATABASE_PORT
            value: "5432"
          - name: DATABASE_URL
            value: "postgres"
          - name: DATABASE_USER
            valueFrom:
              secretKeyRef:
                name: "db-user"
                key: "username"
          - name: DATABASE_PASSWORD
            valueFrom:
              secretKeyRef:
                name: "db-user-pass"
                key: "password"
          - name: REDIS_URL
            value: "redis"
          - name: REDIS_PORT
            value: "6379"
          - name: RAILS_ENV
            value: "production"
          - name: WEBPACKER_DEV_SERVER_HOST
            value: "0.0.0.0"
          - name: SECRET_KEY_BASE
            valueFrom:
              secretKeyRef:
                name: "secret-key-base"
                key: "secret-key-base"
-- markhorrocks
digital-ocean
docker
docker-compose
kubernetes

1 Answer

12/27/2018

Your deployment.yaml has following :

command: ["bin/bash","-c", "./bin/webpack_dev_server"]

There is no bin/bash present in docker image. It should be like:

command: ["/bin/bash","-c", "./bin/webpack_dev_server"]

I believe, it will resolve your problem.

EDIT1: I again looked at your docker-compose.yml file and see the following line:

volumes:
- .:/usr/src/app

It means at run time of docker you copied all the files from . directory to /usr/src/app. Is the config/webpacker.yml was present at that location? OR you overlayed /usr/src/app from whatever it was in . directory at the run time. Could you please share DockerFile of your app as well to better understanding?

-- Prafull Ladha
Source: StackOverflow