<p>I am trying to mount remote path inside docker container image using sshfs, which will going to run on kubernetes cluster.</p>
<p><strong>Problem</strong>
The issue is there is not error &amp; after run the server nginx does not respond. If I comment the <code>CMD</code> part its working.</p>
<p>Nginx Pod Status is <code>CrashLoopBackOff</code> but when not running the sshfs, its working</p>
<p><strong>Dockerfile-nginx</strong></p>
<pre><code>FROM nginx:1.20.2-alpine

RUN apk update &amp;&amp; apk upgrade &amp;&amp; apk add sshfs

COPY nginx/key.pem /home/files

RUN echo &quot;user_allow_other&quot; | tee -a /etc/fuse.conf
RUN mkdir -p /mnt/shared
RUN chmod 600 /home/files/key.pem

CMD sh -c &quot;sshfs root@x.x.x.x:/home /mnt/shared -o debug -o allow_other -o idmap=user,uid=$(id -u),gid=$(id -g) -o ssh_command='ssh -i /home/files/key.pem -o StrictHostKeyChecking=no'&quot;
</code></pre>
<p><strong>Kubernetes Pod</strong></p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
        - name: nginx
          image: kube_nginx:latest
          imagePullPolicy: Never
          ports:
            - containerPort: 80
          securityContext:
            privileged: true
---
apiVersion: v1
kind: Service
metadata:
  name: nginx
spec:
  selector:
    app: nginx
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
  type: LoadBalancer

</code></pre>
<p>Thank you in advance</p>

<p>I resolved the issue.</p>
<p>If anyone facing this issue here is the entire code</p>
<p><strong>Dockerfile-nginx</strong></p>
<pre><code>FROM nginx:1.20.2-alpine

RUN apk update &amp;&amp; apk upgrade &amp;&amp; apk add sshfs

COPY nginx/key.pem /home/files

RUN mkdir -p /mnt/shared
RUN chmod 600 /home/files/key.pem

CMD sh -c &quot;sshfs root@x.x.x.x:/home /mnt/shared -o IdentityFile=/home/files/key.pem -o StrictHostKeyChecking=no &amp;&amp; nginx -g 'daemon off;'&quot;

</code></pre>
<p><strong>Kubernetes Pod</strong></p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      hostPID: true
      containers:
        - name: nginx
          image: kube_nginx:latest
          imagePullPolicy: Never
          ports:
            - containerPort: 80
          securityContext:
            privileged: true
---
apiVersion: v1
kind: Service
metadata:
  name: nginx
spec:
  selector:
    app: nginx
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
  type: LoadBalancer


</code></pre>
