Docker and NodeJS permission denied

I know, this question is not really about programming..

I have a ‘Alpine’ docker container, with a user ‘web’ I can install NodeJS, install some modules with npm install and start the dev server (or prod server).

  • docker for windows mount a folder but can't open it after several hours
  • Exposing a WSGI app from a Docker container
  • how to cache post requests with varnish?
  • Copy Postgres database structures but not data
  • Simple pipeline script for jenkins and docker
  • Unable to download docker golang image: No command specified
  • But when I launch docker commit, the new image has the new directories, but ‘web’ has not the permission to cd or ls in the directories. Even with chmod as root, after that, my user obtains Permission denied on all the home dir… Like if the directories was corrupted.. (but I can browse it with root).

    I don’t want to launch the app with root.

    EDIT 2 : Finally, I have the same problem just with the following Dockerfile :

    FROM alpine:3.2
    RUN adduser -D web
    RUN echo "web   ALL=(ALL:ALL)   NOPASSWD:       ALL " > /etc/sudoers
    
    USER web
    WORKDIR "/home/web"
    
    ADD ./FOLDER /home/web
    EXPOSE 8080 5000
    

    And it doesn’t work too… Maybe it’s a problem with Alpine ?

    EDIT : with Dockerfile.
    I start from a Node BASE image which has the following operations :

    FROM alpine:3.2
    ENV NODE_VERSION=v4.2.4
    ENV NPM_VERSION=2
    
    RUN apk --update --virtual build_dependencies \
        make gcc g++ python linux-headers paxctl krb5-dev \
        automake autoconf nasm git curl file sudo binutils-gold && \
        apk add --update krb5-libs libgcc libstdc++ && \
    curl -sSL https://nodejs.org/dist/${NODE_VERSION}/node-${NODE_VERSION}.tar.gz | tar -xz && \
    
    cd /node-${NODE_VERSION} && \
        ./configure --prefix=/usr && \
        make -j $(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1) && \
        make install && \
        paxctl -cm /usr/bin/node && \
        rm -rf /etc/ssl /node-${NODE_VERSION}
    
    RUN cd / && \
        if [ -x /usr/bin/npm ]; then \
                npm install -g npm@${NPM_VERSION} && \
                find /usr/lib/node_modules/npm -name test -o -name .bin -type d | xargs rm -rf; \
        fi
    
    RUN rm -rf /usr/share/man /tmp/* /var/cache/apk/* /root/.npm /root/.node-gyp \
        /usr/lib/node_modules/npm/man /usr/lib/node_modules/npm/doc /usr/lib/node_modules/npm/html
    
    RUN adduser -D web
    ENV PATH $PATH:/home/web/node_modules/.bin
    

    From there, I execute some following operations :

    git config --global http.sslVerify false
    git clone "GIT_REPO"
    cd GIT_REPO
    git checkout dev
    npm config set strict-ssl false
    git config --global http.proxy "PROXY"
    git config --global https.proxy "PROXY
    npm config set proxy "PROXY"
    npm config set https-proxy "PROXY"
    npm install --production
    npm install forever
    

    But if I create myself a directory ‘/home/web/TEST’, ‘web’ is able to browse, even after a commit. I remove too all specified .git files before install with npm.

  • Pull docker image from AWS ECR using remote API
  • How to overwrite a configuration file with Docker
  • Ensure docker daemon is running on the host in script file
  • Jboss 5.1 in Dockerfile - how to reach the server in a browser
  • Docker-Compose Restart Policy
  • How can I increase my Docker Sonarqube disk space to avoid this warning?
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.