Permission denied error with Docker Update Module

Hi @lluiscampos ,

Im using this Module to update a Azure repo,
I’m getting this unauth error, I have logged into docker and azure creds, But still I get this:

WARNING: Error loading config file: /home/mender/.docker/config.json: stat /home/mender/.docker/config.json: permission denied
Error response from daemon: Get https:/azurecr.io/manifests/4.1: unauthorized: authentication required, visit https://aka.ms/acr/authorization for more information.

This is how I’m trying to create the release :,
ARTIFACT_NAME=“load-update-1.0”
DEVICE_TYPE=“cam”
OUTPUT_PATH=load-container-update-1.0.mender
DOCKER_IMAGES=“0.azurecr.io/load/local:.1
./docker-artifact-gen -n {ARTIFACT_NAME} -t {DEVICE_TYPE} -o {OUTPUT_PATH} {DOCKER_IMAGES}

But when I give sudo ./docker-artifact-gen -n {ARTIFACT_NAME} -t {DEVICE_TYPE} -o {OUTPUT_PATH} {DOCKER_IMAGES}, then error goes away, and It starts pulling the image, but at the end I get “Required flag " f” not set"

Please tell me, what is that Im doing wrong here

FYI: I’m able to docker pull normally, so why is this giving error

Hello @nishad1092,

Once you are logged in into the Docker Registry (via docker login), the script docker-artifact-gen should be able to pull the image without requiring sudo. Actually, using sudo will make the script not to be able to pull the image…

Try to pull manually the image before running the script and post us here your results:

docker pull 0.azurecr.io/load/local:.1
./docker-artifact-gen -n ${ARTIFACT_NAME} -t ${DEVICE_TYPE} -o ${OUTPUT_PATH} ${DOCKER_IMAGES}

Note: All shell variables require a “$” symbol!

I did pull manually and tried doing the same, but still the error exist:
@lluiscampos

WARNING: Error loading config file: /home/mender/.docker/config.json: stat /home/mende/.docker/config.json: permission denied
Error response from daemon: Get https://0.azurecr.io/v2/ca/local/manifests/0.1: unauthorized: authentication required, visit https://aka.ms/acr/authorization for more information.

@nishad1092 Is that the output from the docker pull command or the ./docker-artifact-gen one?

Also, there is a very suspicious typo there: “stat /home/mende/.docker/config.json” -> shouldn’t it be mender ?

@nishad1092 Check that the file exists and that it has the correct permissions with:

stat /home/mende/.docker/config.json

Hi @lluiscampos,

It is the output from ./docker-artifact-gen -n {ARTIFACT_NAME} -t {DEVICE_TYPE} -o {OUTPUT_PATH} {DOCKER_IMAGES}

and the err msg is:
Error loading config file: /home/mender/.docker/config.json: stat /home/mender/.docker/config.json: permission denied
Error response from daemon: Get https://0.azurecr.io/v2/c/local/manifests/4.0.1: unauthorized: authentication required, visit https://aka.ms/acr/authorization for more information.

There is a config.json file in that location and also it has a content which mentions:

{
        "auths": {
                "0.azurecr.io": {
                        "auth": "xxxxxxxxxxxxxxxxxxxx"
                }
        },
        "HttpHeaders": {
                "User-Agent": "Docker-Client/19.03.6 (linux)"
        }
}

And it has root root permission for both user and group

I got:

stat: cannot stat ‘/home/mender/.docker/config.json’: Permission denied

It has root permission, Should I change it to mender perm for user and group?

Change the permissions to what ever user you are running as, e.g you can run:

$ id

To find this out. The docker commands in the script are run as a regular user as you can see here. This is why sudo ./docker-artifact-gen ... does not help

Also it is probably best to update your docker permissions so you do not need sudo (which I think is the root problem),

1 Like

Hi @mirzak, @lluiscampos
I changed the permission of that config.json to the current user i use, and I ran

./docker-artifact-gen -n {ARTIFACT_NAME} -t {DEVICE_TYPE} -o {OUTPUT_PATH} {DOCKER_IMAGES}
but I got this error this time,

./docker-artifact-gen: line 116: meta-data.json: Permission denied

Sure do that… Thanks for the info @mirzak

Hi @mirzak,

Thanks for taking this issue as a seperate branch topic.

So this is what I get now. After giving perm to /home/mender/.docker/config.json, the previous error is gone but got this new permission denied.

First time having perm issue while creating a artifact

@nishad1092 Then just remove the old meta-data file with:

sudo rm meta-data.json 

and try again :slight_smile:

Hi @lluiscampos,

I did this, and I ran it again,:
But I got this again:
4.0.1: Pulling from ca/local
Digest: sha256:6a095669f2819b3dcafe3f5bfe70f72c9338d3da390
Status: Image is up to date for 0.azurecr.io/ca/local:4.0.1

Required flag " f" not set

really didnt understand why is this happening?

@nishad1092 Can you post the full command and the bash variables that you are using?

Hi @lluiscampos
Sure,

ARTIFACT_NAME=“cam-update_1.0”
DEVICE_TYPE=“cam_node”
OUTPUT_PATH=“cam-update-1.0.mender”
DOCKER_IMAGES=“0.azurecr.io/cam/local:4.0
./docker-artifact-gen -n {ARTIFACT_NAME} -t {DEVICE_TYPE} -o {OUTPUT_PATH} {DOCKER_IMAGES}

@nishad1092 Aren’t you missing the $ symbols?

ARTIFACT_NAME=“cam-update_1.0”
DEVICE_TYPE=“cam_node”
OUTPUT_PATH=“cam-update-1.0.mender”
DOCKER_IMAGES=“0.azurecr.io/cam/local:4.0”
./docker-artifact-gen -n ${ARTIFACT_NAME} -t ${DEVICE_TYPE} -o ${OUTPUT_PATH} ${DOCKER_IMAGES}

Hi @lluiscampos,

Sorry, I dont know how that went got away in the previous post, Im giving the and passing the variables:

i pasted right into this box, but after saving my reply, the $ vanishes, Sorry for that, I didn’t pay attn. there.

@nishad1092 Mmm. Which version of mender-artifact are you running? Can you do:

mender-artifact --version

and copy here the output?