DEV Community


Posted on

How to troubleshoot docker unauthorized 401 error

This is an example from a public repository that was causing an issue.

I created a account which comes with one free repository.

Then proceed with the steps below:

Here is my test Dockerfile:

FROM openjdk:8-jdk-alpine

WORKDIR /opt/app

COPY target/aamdevsecops-1.1.1-SNAPSHOT.jar /opt/app/

CMD ["java","-jar","aamdevsecops-1.1.1-SNAPSHOT.jar"]
Enter fullscreen mode Exit fullscreen mode

Of course, i changed the <name>, <version> and <artifactoryId> in pom.xml file to match my Dockerfile.

First, i built the package locally by issuing this command on the intense-api git project folder:

mvn package

Then, I built the docker image out of it:

docker build -t aamdevsecops:1.1.1 .

then logged in to docker with my credentials.

docker login # you will be prompted for credentials of account

tagged the image: docker tag aamdevsecops/devops-bootcamp:latest

then: docker push aamdevsecops/devops-bootcamp:1.1.1

Finally, I did:

docker run --name aamdevsecops -p 8090:8090 aamdevsecops/devops-bootcamp:latest

And here's the result:

Image description

My Dockerfile

FROM openjdk:8-jdk-alpine
WORKDIR /opt/app

COPY target/pichk-0.0.1-SNAPSHOT.jar /opt/app/

CMD ["java","-jar","pichk-0.0.1-SNAPSHOT.jar"]

When I run image

docker run -p 8090:8090 pichk:001

I got error

docker: you are not authorized to perform this operation: server returned 401.

I am adding target permissions line

drwxrwxr-x   9 miki miki  4096 Jan  4

Top comments (0)