0

I am trying to build a Docker Image from a simple Spring RESTful web service jar.

For that I have specified the following Dockerfile:

FROM openjdk:8-jdk-alpine VOLUME /tmp ARG JAR_FILE ADD ${JAR_FILE} app.jar ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"] 

I am trying to "Build a Docker Image with Maven" from my IDEA cli like stated in the instructions here

./mvnw install dockerfile:build 

Unfortunately this throws an exception:

Could not build image: java.util.concurrent.ExecutionException: com.spotify.docker.client.shaded.javax.ws.rs.ProcessingException: java.io.IOException: Permission denied 

Since I don't know how to solve this I tried to build an image from the terminal with docker command:

$ docker build nordic/demo 

Which created the image but with name and tag as <none>. Read about it from docker documentations but nothing said about that.

I am new to Docker so im sure there is some fundamental misunderstanding in how to build the Docker Image. Mainly:

  1. When building from terminal how does Docker know how to name the Image?
  2. When building with spotify plugin, why/what permissions are required to use the plugin (logging in to dockerhub before the build didn't help)?

Thanks for any pointers or explanations!

3 Answers 3

1

Set the permission in /var/run/docker for your_own_username instead of root using the below example command, then give a try.

sudo chown -R root:your_own_username /var/run/docker

Sign up to request clarification or add additional context in comments.

Comments

0

spring boot docker

this link will be helpful to build your docker image with spring boot.

<properties> <docker.image.prefix>springio</docker.image.prefix> </properties> <build> <plugins> <plugin> <groupId>com.spotify</groupId> <artifactId>dockerfile-maven-plugin</artifactId> <version>1.3.6</version> <configuration> <repository>${docker.image.prefix}/${project.artifactId}</repository> <buildArgs> <JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE> </buildArgs> </configuration> </plugin> </plugins> </build> 

this plugin you to include in your pom, you can change you image name in properties field.

if you are getting permission denied error, you have to run it with sudo command

Comments

0

When you run command:

docker build -t demo:1 . 

in string 'demo:1' demo is repository name and string after colon '1' is tag of image and dot (.) in the end means current directory is build context where your Dockerfile is residing.

A repository can have many images and they are uniquely identified by tag. If you run command like this without providing tag:

docker build -t demo . 

docker will create new image in demo repository and by default attach tag named 'latest' with image, so image in this case will be demo:latest. And repository demo will have 2 images demo:1 and demo:latest. Also tag 'latest' does not mean image is latest it is just name of tag.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.