3

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

Talisker
  • 177
  • 2
  • 16

2 Answers2

4

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/

Talisker
  • 177
  • 2
  • 16
3

This is likely caused by you trying to run a image which requires it be run as root. You should aim to construct your image so it can be run as any user ID.

First off I would suggest trying to use the nodejs S2I builder image supplied with OpenShift.

Next would be to modify your image so can run as any user ID per guidelines at:

Finally, if you can't fix the image for some reason, you would as a OpenShift cluster admin configure the project to allow you to run images as root.

For Minishift, see details of the anyuid add on which makes that a bit easier.

Graham Dumpleton
  • 57,726
  • 6
  • 119
  • 134