mardi 5 juillet 2016

Files created inside docker are write protected on host

I am using docker container for rails and ember.I am mounting the source from my local to the container. All the changes I make here on local are reflected in the container.

Now I want to use generators to create files. The files are created, but they are write protected on my machine.

When I try to do dokcer-compose run frontend bash, I get a root@061e4159d4ef:/frontend# superuser prompt access inside of the container. I can create files when I am in this mode. These files are write protected in my host.

I have also tried docker-compose run --user "$(id -u):$(id -g)" frontend bash, I get a I have no name!@31bea5ae977c:/frontend$, I am unable to create any file in this mode. Below is the error message that I get.

I have no name!@31bea5ae977c:/frontend$ ember g template about
/frontend/node_modules/ember-cli/node_modules/configstore/node_modules/mkdirp/index.js:90
                    throw err0;
                    ^

Error: EACCES: permission denied, mkdir '/.config'
    at Error (native)
    at Object.fs.mkdirSync (fs.js:916:18)
    at sync (/frontend/node_modules/ember-cli/node_modules/configstore/node_modules/mkdirp/index.js:71:13)
    at Function.sync (/frontend/node_modules/ember-cli/node_modules/configstore/node_modules/mkdirp/index.js:77:24)
    at Object.create.all.get (/frontend/node_modules/ember-cli/node_modules/configstore/index.js:39:13)
    at Object.Configstore (/frontend/node_modules/ember-cli/node_modules/configstore/index.js:28:44)
    at clientId (/frontend/node_modules/ember-cli/lib/cli/index.js:22:21)
    at module.exports (/frontend/node_modules/ember-cli/lib/cli/index.js:65:19)
    at /usr/local/lib/node_modules/ember-cli/bin/ember:26:3
    at /usr/local/lib/node_modules/ember-cli/node_modules/resolve/lib/async.js:44:21

Here is my Dockerfile:

FROM node:6.2

ENV INSTALL_PATH /frontend
RUN mkdir -p $INSTALL_PATH

WORKDIR $INSTALL_PATH

# Copy package.json separately so it's recreated when package.json
# changes.
COPY package.json ./package.json
RUN npm install
COPY . $INSTALL_PATH
RUN npm  install -g phantomjs bower ember-cli ;\
    bower --allow-root install

EXPOSE 4200
EXPOSE 49152

CMD [ "ember", "server" ]

Here is my docker-compose.yml file, please note it is not in the current directory, but the parent.

frontend:
   build: "frontend/"
   dockerfile: "Dockerfile"
   environment:
      - EMBER_ENV=development
   ports:
      - "4200:4200"
      - "49152:49152"
   volumes:
      - ./frontend:/frontend

I want to know, how can I use generateors? I am new to learning docker. Any help is appreciated. Thanks.




Aucun commentaire:

Enregistrer un commentaire