0

[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.7.4:build-image (default) on project twitter-to-kafka-service: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:2.7.4:build-image failed: Connection to the Docker daemon at 'localhost' failed with error "[13] Permission denied"; ensure the Docker daemon is running and accessible: com.sun.jna.LastErrorException: [13] Permission denied -> [Help 1]

I get the above error when I try to create an image using the spring-boot-maven-plugin. To solve the problem, I gave all privileges to the terminal with sudo su and the problem was solved.

However, I ran into a more interesting problem. Normal user cannot access the image created after typing sudo su. So in the Docker Desktop application, and when I type docker images in the terminal, I can't see the created images. Whenever I type sudo su and then docker images then I can view it. I don't want it to be this way either. Because it is easier to use Docker Desktop application.

docker images
REPOSITORY   TAG       IMAGE ID   CREATED   SIZE


sudo su
[sudo] password for umut: 
root@umut-ThinkPad-E14-Gen-2:/home/umut# docker images
REPOSITORY                          TAG              IMAGE ID       CREATED        SIZE
paketobuildpacks/run                base-cnb         320a67ab6606   2 weeks ago    87.8MB
tedex123/twitter-to-kafka-service   0.0.1-SNAPSHOT   a94cc13fed95   42 years ago   291MB
paketobuildpacks/builder            base             49d8ba727b2b   42 years ago   1.34GB
Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
  • Why would you run `sudo su`? You either run `sudo ` to execute that as superuser, _or_ you use `su` to **s**ubstitute a **u**ser. You _never_ need to `sudo` the `su` command, the whole point is that you're asking the OS to change to a different user, which it will let you do as long as you provide the correct credentials for that user. – Mike 'Pomax' Kamermans Oct 05 '22 at 16:29
  • Do you mean I should use instead of ```sudo su``` then ```mvn install```, just use ```sudo mvn install```? Well, if you mean that I tried that but it's still the same. – Umut Emre Önder Oct 05 '22 at 16:44
  • Sounds like you forgot to add your user to the docker group. I.e. https://stackoverflow.com/a/48957722/740553 – Mike 'Pomax' Kamermans Oct 05 '22 at 17:55

0 Answers0