DEV Community

aamdevsecops
aamdevsecops

Posted on

1

How to troubleshoot docker unauthorized 401 error

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

https://github.com/MilenkoMarkovic/intens-api-2022

I created a hub.docker.com 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 hub.docker.com credentials.

docker login # you will be prompted for credentials of hub.docker.com 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"]
EXPOSE 8090

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)

Great read:

Is it Time to go Back to the Monolith?

History repeats itself. Everything old is new again and I’ve been around long enough to see ideas discarded, rediscovered and return triumphantly to overtake the fad. In recent years SQL has made a tremendous comeback from the dead. We love relational databases all over again. I think the Monolith will have its space odyssey moment again. Microservices and serverless are trends pushed by the cloud vendors, designed to sell us more cloud computing resources.

Microservices make very little sense financially for most use cases. Yes, they can ramp down. But when they scale up, they pay the costs in dividends. The increased observability costs alone line the pockets of the “big cloud” vendors.

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay