title: How to run Mongodb Docker image pulled from docker hub running in OpenShift
body: <p>I need to deploy an application on openshift which is highly dependent on MongoDB to bring the main API pod. The constraint over here is the MongoDB image used in the deployment requires to run as root but openshift doesn't allow that. Is there a walk around this?</p>
  
  <p>I have already tried the solution mentioned under this link 
  <a href="https://github.com/openshift/origin/issues/17164" rel="nofollow noreferrer">https://github.com/openshift/origin/issues/17164</a></p>
  
  <p>Deployment.yaml</p>
  
  <pre><code>- apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
    kind: Deployment
    metadata:
      name: mongo
      namespace: default
    spec:
      selector:
        matchLabels:
          app: mongo
          role: master
          tier: backend
      replicas: 1
      template:
        metadata:
          labels:
            app: mongo
            role: master
            tier: backend
        spec:
          initContainers:
            - name: config-data-path
              image: busybox
              command: 
                - /bin/chmod
                - -R
                - "777"
                - /data/db
              volumeMounts:
                - name:  data
                  mountPath: /data/db
          containers:
            - name: mongo
              image: mongo
              ports:
                - containerPort: 27017
              volumeMounts:
                - name: data
                  mountPath: /data/db
          volumes:
            - name: data
              persistentVolumeClaim:
                claimName: mongo-pv-claim
  </code></pre>
  
  <p>Error log from the container.</p>
  
  <pre><code>chmod: /data/db: Permission denied
  chmod: /data/db: Permission denied
  </code></pre>