Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker-compose builds as root #90

Closed
smishr4 opened this issue Feb 8, 2018 · 5 comments
Closed

docker-compose builds as root #90

smishr4 opened this issue Feb 8, 2018 · 5 comments

Comments

@smishr4
Copy link

smishr4 commented Feb 8, 2018

First, thank you very much for this wonderful node-boilerplate, It really does cover a long tech stack which I am trying to complete bit by bit.

Problem which I encountered when I tried to run this as described, simply did:
cd nodejs-api-starter
docker-compose up

And I get this error:
api_1 | EACCES: permission denied, mkdir 'build/emails'
api_1 | EACCES: permission denied, mkdir 'build/emails'
...
and so on.

The problem here is that the build directory created by running build.js through docker-compose is root protected and doesn't allow any further changes, so the build process fails and finally the ./build/server.js is unavailable. I can manually create a build directory that is not root protected and repeat the process then it works. Probably something to do with docker's functioning and my lack of experience in working with it. Can you help me figure out a work around?

screenshot:
http://i.imgur.com/ckiomWY.png

@smishr4
Copy link
Author

smishr4 commented Feb 8, 2018

And I forgot to mention, my operating system is ubuntu-16.04 -- xfce desktop

@shadowbrush
Copy link

Out of the box, Docker on Ubuntu requires root, see: https://askubuntu.com/questions/477551/how-can-i-use-docker-without-sudo

@smishr4
Copy link
Author

smishr4 commented Feb 8, 2018

That I fixed when I tried my first docker program. I made a small express program, and a simple Dockerfile:
# Use latest node image
FROM node:9-alpine
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
CMD ["npm", "start" ]
EXPOSE 4000

and I built image using the following:
docker build -t node-docker .
and then ran the image using:
docker run -p 4000:4000 -v ~/testProjects/node-docker/:/usr/src/app node-docker

the source, node_modules and package.json everything inside my project directory and I am able to run this without sudo after adding the $USER to docker usergroup.

but I still have the problem that I created the issue for.

@ghost
Copy link

ghost commented Feb 9, 2018

@smishr4 On our side, other than running an initial mkdir build as the account running docker-compose up. I don't know another way around it. The interesting thing is that this only happens for me on my ubuntu server, not on my local macOS. would be curious as to why that initial folder creation is run under root context.

@smishr4
Copy link
Author

smishr4 commented Feb 9, 2018

I think probably something to do the way docker creates the directory on linux machine.
docker/compose#2781 (comment)

https://stackoverflow.com/questions/33509752/docker-compose-creates-file-owned-by-root

Anyways instead of doing mkdir build the neater solution would be to just give the permission using chown

Doing this works too:

sudo chown -R $USER:$USER .
docker-compose up

Thanks
Since this is problem with the way docker is working on ubuntu, you can close this issue and create a reference. Again its a great project and I am kinda struggling with graphql-relay as I have only learned graphql just recently using express-graphql with graphiql interface to write queries, if you can suggest me a good place to start from, that would be a good help.

@koistya koistya closed this as completed Feb 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants