Resin nmcli permission denied

raspberrypi3

#1

Hello,

I am trying to make nmcli run inside the app container, so I can change some network settings.

# base-image for node on any machine using a template variable,
# see more about dockerfile templates here: http://docs.resin.io/deployment/docker-templates/
# and about resin base images here: http://docs.resin.io/runtime/resin-base-images/
# Note the node:slim image doesn't have node-gyp
FROM resin/%%RESIN_MACHINE_NAME%%-node:6-slim


# Enable systemd init system in container
ENV INITSYSTEM on


# use apt-get if you need to install dependencies,
# for instance if you need ALSA sound utils, just uncomment the lines below.
#RUN apt-get update && apt-get install -yq \
#    alsa-utils libasound2-dev && \
#    apt-get clean && rm -rf /var/lib/apt/lists/*

#RUN apt-get update && apt-get install network-manager


RUN apt-get update && apt-get install network-manager && \
	apt-get clean && \
	systemctl mask NetworkManager.service

WORKDIR /usr/src/app

COPY . .

RUN ["chmod","+x","nmcli"]

#CMD ./nmcli

# Defines our working directory in container
#WORKDIR /usr/src/app

# Copies the package.json first for better cache on later pushes
COPY package.json package.json

# This install npm dependencies on the resin.io build server,
# making sure to clean up the artifacts it creates in order to reduce the image size.
RUN JOBS=MAX npm install --production --unsafe-perm && npm cache clean && rm -rf /tmp/*

# This will copy all files in our root to the working  directory in the container
COPY . ./

# server.js will run when container starts up on the device
CMD ["npm", "start"]

CMD ./nmcli

#CMD ["nmcli","--nocheck", "connection","up","resin-wifi-02"]

I try to set RUN chmod +x nmcli, but it still gives me the error:

23.01.18 04:34:15 (+0100) /bin/sh: 1: ./nmcli: Permission denied

What am I doing wrong? Thanks for help


#4

Hello,

would you like to check this sample project out?

Is there a chance you are missing this? https://github.com/resin-io-playground/resin-nmcli/blob/master/nmcli#L2

Best,
ilias


#5

Hello,

this is what I used. I have put the nmcli wrapper file into the folder. That is why I am confused.

I even tried to use this project standalone on a raspberry pi. I get errors:

[Info]     Starting build for itadmin/nmclitest, user itadmin
[Info]     Dashboard link: https://dashboard.resin.io/apps/943444/devices
[Info]     Building on arm01
[Info]     Fetching base image
[Warning]  No image tag given for resin/raspberrypi3-debian, using default (latest)
[==================================================>] 100%
[Info]     Building Dockerfile.template project
[Build]    Step 1/7 : FROM resin/raspberrypi3-debian
[Build]     ---> 59d16f24d514
[Build]    Step 2/7 : ENV INITSYSTEM on
[Build]     ---> Running in d78b25b9141a
[Build]     ---> 3d01d6eeb366
[Build]    Removing intermediate container d78b25b9141a
[Build]    Step 3/7 : RUN echo "deb http://ftp.debian.org/debian stretch-backports main" >> /etc/apt/sources.list
[Build]     ---> Running in 714863dfab1c
[Build]     ---> 7629be78bf00
[Build]    Removing intermediate container 714863dfab1c
[Build]    Step 4/7 : RUN apt-get update && apt-get -t stretch-backports install -yq 	network-manager && 	apt-get clean && rm -rf /var/lib/apt/lists/* && systemctl mask NetworkManager.service
[Build]     ---> Running in fbcafdde1b7b
[Build]    Get:1 http://security.debian.org jessie/updates InRelease [63.1 kB]
[Build]    Get:2 http://archive.raspbian.org jessie InRelease [14.9 kB]
[Build]    Get:3 http://ftp.debian.org stretch-backports InRelease [91.8 kB]
[Build]    Get:4 http://archive.raspberrypi.org jessie InRelease [22.9 kB]
[Build]    Ign http://deb.debian.org jessie InRelease
[Build]    Get:5 http://deb.debian.org jessie-updates InRelease [145 kB]
[Build]    Get:6 http://deb.debian.org jessie Release.gpg [2434 B]
[Build]    Get:7 http://deb.debian.org jessie Release [148 kB]
[Build]    Get:8 http://security.debian.org jessie/updates/main armhf Packages [593 kB]
[Build]    Get:9 http://archive.raspbian.org jessie/main armhf Packages [13.3 MB]
[Build]    Get:10 http://ftp.debian.org stretch-backports/main armhf Packages [289 kB]
[Build]    Get:11 http://archive.raspbian.org jessie/contrib armhf Packages [49.5 kB]
[Build]    Get:12 http://archive.raspbian.org jessie/non-free armhf Packages [101 kB]
[Build]    Get:13 http://archive.raspbian.org jessie/rpi armhf Packages [1297 B]
[Build]    Get:14 http://archive.raspbian.org jessie/firmware armhf Packages [1202 B]
[Build]    Get:15 http://archive.raspberrypi.org jessie/main armhf Packages [171 kB]
[Build]    Get:16 http://deb.debian.org jessie-updates/main armhf Packages [23.0 kB]
[Build]    Get:17 http://deb.debian.org jessie/main armhf Packages [8864 kB]
[Build]    Fetched 23.9 MB in 10s (2308 kB/s)
[Build]    Reading package lists...
[Build]    Reading package lists...
[Build]    Building dependency tree...
[Build]    Reading state information...
[Build]    Some packages could not be installed. This may mean that you have
[Build]    requested an impossible situation or if you are using the unstable
[Build]    distribution that some required packages have not yet been created
[Build]    or been moved out of Incoming.
[Build]    The following information may help to resolve the situation:
[Build]    The following packages have unmet dependencies:
[Build]     network-manager : Depends: libpam-systemd but it is not going to be installed
[Build]                       Depends: policykit-1 but it is not going to be installed
[Build]    E: Unable to correct problems, you have held broken packages.
[Build]    Removing intermediate container fbcafdde1b7b
[Error]    Build failed: The command '/bin/sh -c apt-get update && apt-get -t stretch-backports install -yq 	network-manager && 	apt-get clean && rm -rf /var/lib/apt/lists/* && 	systemctl mask NetworkManager.service' returned a non-zero code: 100
[Info]     Uploading successful layers to registry for caching purposes
[==================================================>] 100%
[Info]     Successfully updated cache.

#6

It worked with and edited slimmed down version

FROM resin/%%RESIN_MACHINE_NAME%%-node:6-slim

ENV INITSYSTEM on

#RUN echo "deb http://ftp.debian.org/debian stretch-backports main" >> /etc/apt/sources.list

RUN apt-get update && \
	apt-get install network-manager && \
	systemctl mask NetworkManager.service

WORKDIR /usr/src/app

COPY . .

CMD ./nmcli