Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 375
Talisker Avatar asked Nov 18 '25 16:11

Talisker


2 Answers

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/

like image 91
Talisker Avatar answered Nov 21 '25 08:11

Talisker


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.

  • https://github.com/sclorg/s2i-nodejs-container

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

  • https://docs.openshift.org/latest/creating_images/guidelines.html

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.

  • https://docs.openshift.org/latest/minishift/using/addons.html
like image 40
Graham Dumpleton Avatar answered Nov 21 '25 09:11

Graham Dumpleton



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!