dockeropenshiftminishiftmountebank

Permission issues when deploying docker image in OpenShift/Minishift


This question relates to the local version of OpenShift, Minishift. I am runnning on MacOS.

I am attempting to deploy an application called Mountebank from docker hub, here is the source:

https://hub.docker.com/r/andyrbell/mountebank/

The DockerFile goes as follows:

FROM alpine:3.6
EXPOSE 2525
CMD ["mb"]
ENV NODE_VERSION=6.10.3-r1

RUN apk update \
  && apk add --no-cache nodejs=${NODE_VERSION} \
  && apk add --no-cache nodejs-npm=${NODE_VERSION}

ENV MOUNTEBANK_VERSION=1.13.0

RUN npm install -g mountebank@${MOUNTEBANK_VERSION} --production \    
  && npm cache clean \
  && rm -rf /tmp/npm*

I can run the Mountebank image within a container locally on MacOS fine.

When I install the image inside Minishift and attempt to start a pod, I get the following error:

    /usr/lib/node_modules/mountebank/node_modules/q/q.js:155 
    throw e; 
    ^ 
    Error: EACCES: permission denied, open 'mb.pid' 
    at Error (native) 
    at Object.fs.openSync (fs.js:641:18) 
    at Object.fs.writeFileSync (fs.js:1347:33) 
    at /usr/lib/node_modules/mountebank/bin/mb:176:16 
    at _fulfilled (/usr/lib/node_modules/mountebank/node_modules/q/q.js:854:54) 
    at self.promiseDispatch.done (/usr/lib/node_modules/mountebank/node_modules/q/q.js:883:30) 
    at Promise.promise.promiseDispatch (/usr/lib/node_modules/mountebank/node_modules/q/q.js:816:13) 
    at /usr/lib/node_modules/mountebank/node_modules/q/q.js:624:44 
    at runSingle (/usr/lib/node_modules/mountebank/node_modules/q/q.js:137:13) 
    at flush (/usr/lib/node_modules/mountebank/node_modules/q/q.js:125:13)

I am assuming this is related to permission issues under which my pod is running in Minishift, but am unaware how to go about changing them.

Any help is appreciated,

Many thanks


Solution

  • OK, so here's how I fixed my issues. I moved the location where the mb.pid and mb.log files were going to be stored. They were initially stored at root, which caused problems when the image was hosted within Minishift:

    FROM alpine:3.6
    
    EXPOSE 2525
    
    CMD mb --pidfile /tmp/mb.pid --logfile /tmp/mb.log
    
    ENV NODE_VERSION=6.10.3-r1
    
    RUN apk update \
    && apk add --no-cache nodejs=${NODE_VERSION} \
    && apk add --no-cache nodejs-npm=${NODE_VERSION}
    
    ENV MOUNTEBANK_VERSION=1.13.0
    
    RUN npm install -g mountebank@${MOUNTEBANK_VERSION} --production \
    && npm cache clean \
    && rm -rf /tmp/npm*
    

    Notice the --pidfile --logfile storing the files in /tmp/