docker build --pull -t "$DOCKER_REGISTRY_IMAGE" . ``` in my YML file it gives me the following error
#7 sha256:dfa2ef75c7954aaee8f870047cbaf47a407eb186847ff19b01de4c198fb4fa00
#7 ERROR: lstat /var/lib/docker/tmp/buildkit-mount254857695/build/libs: no such file or directory
------
> [2/2] COPY build/libs/*.jar app.jar:
------
lstat /var/lib/docker/tmp/buildkit-mount254857695/build/libs: no such file or directory
When I run the same command in IntelliJ it works.
This is my YML file (The docker part)
deploy-docker:
image: docker:latest
stage: deploy-docker
services:
- docker:dind
before_script:
- docker login -u "$DOCKER_REGISTRY_USER" -p "$DOCKER_REGISTRY_PSW"
script:
- cd goatpool-backend
- docker build --pull -t "$DOCKER_REGISTRY_IMAGE" .
- docker push "$DOCKER_REGISTRY_IMAGE"
this is my Dockerfile content:
FROM openjdk:11
VOLUME /tmp
COPY build/libs/*.jar app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
Related
I'm trying to deploy a war file downloaded from an S3 Bucket to a Tomcat created docker container deployed in kubernetes but I'm getting the following error:
download failed: s3://folder/myapp.war to ../../usr/local/tomcat/webapps/myapp.war [Errno 30] Read-only file system: '/usr/local/tomcat/webapps/myapp.war.8bEd47FD'
This is my Dockerfile, AWS configuration comes directly from k8s configuration
FROM tomcat:9.0
COPY --from=0 /usr/local/bin/creds-helper /usr/local/bin/creds-helper
RUN apt-get update && apt-get install -y --no-install-recommends python3 python3-pip python3-setuptools
RUN pip3 install awscli
RUN mkdir -p /scripts
COPY k8s/launch.sh /scripts/
RUN useradd -m -u 59417 -d /home/nonroot -s /bin/bash nonroot
USER 59417:59417
CMD ["/bin/bash"]
This is the content of launch.sh
#!/bin/bash
aws s3 cp s3://folder/myapp.war /usr/local/tomcat/webapps/myapp.war
catalina.sh run
This is my k8s deployment:
- command: [bash, -c, bash /scripts/launch.sh]
image: my_dockerfile
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop:
- ALL
imagePullPolicy: Always
name: pod_name
ports:
- {containerPort: 8888}
volumeMounts:
- {mountPath: /home/nonroot, name: nonroot}
- {mountPath: /secrets, name: secrets}
I've also tried in the Dockerfile
RUN chmod 777 /usr/local/tomcat/ and RUN chmod -R a+rwx /usr/local/tomcat/
But nothing have worked to give me write access to de directory to transfer the file, ls -l command shows:
drwxrwxrwx 1 root root 6 Oct 13 18:07 webapps
Any hint or help will be greatly appreciated.
I just want to deploy my springboot applicaiton on the remote centos server through the intellij idea.
First I tried the way of DockerFile to deploy the application on intellij idea and I successed.
this is my DockerFile config
FROM williamyeh/java8
# COPY or ADD to image
COPY dockerdemo-0.0.1-SNAPSHOT.jar app.jar
RUN bash -c "touch /app.jar"
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "app.jar"]
but when I tried the method of docker-compose.yml,I failed,I can't mapped my navtive jar to the remote system.my docker-compose.yml config is
version: "3"
services:
dockerDemo2:
image: adoptopenjdk/openjdk8:latest
container_name: dockerDemo2
privileged: true
environment:
TZ: Asia/Shanghai
LANG: es_US.UTF-8
volumes:
- ./dockerdemo-0.0.1-SNAPSHOT.jar:/docker/dockerdemo-0.0.1-SNAPSHOT.jar
command: bash -c " tail -f /dev/null "
ports:
- 8080:8080
I deployed successed,but when I get in the remote docker ,I found the /docker/dockerdemo-0.0.1-SNAPSHOT.jar is a directory, It should expected as a jar file,but it not,I don't know why that.that's really confuesed me.
I'm trying to deploy my spring boot application with docker compose but get this error:
Step 14/15 : COPY ${JAR_FILE} manager.jar
ERROR: Service 'manager' failed to build : When using COPY with more than one source file, the destination must be a directory and end with a /
But if I do a docker build using the Dokerfile it works correctly. The question is, why fail with docker-compose up?.
C:\Push\Workspace\manager>docker build --tag "docker-manager:latest" .
[+] Building 7.3s (8/8) FINISHED
I have tried looking for examples but I am using windows 10
The Dockerfile:
FROM openjdk:8-jdk-alpine
RUN addgroup -S spring && adduser -S spring -G spring
USER spring:spring
ARG JAR_FILE=target/*.jar
COPY ${JAR_FILE} example.jar
ENTRYPOINT ["java", "-jar", "example.jar"]
The docker-compose.yml
services:
oracle:
image: container-registry-london.oracle.com/database/enterprise:12.2.0.1
ports:
- "8080:8080"
- "1521:1521"
manager:
build: .
ports:
- "8181:8181"
depends_on:
- oracle
links:
- oracle
restart: always
I am guessing there might be mulitple jar files in your target folder.
In stead of using the *.jar , please use full name of the jar and then rebuild the dokcer compose file with --build flag.
ARG JAR_FILE=target/test-0.0.1-SNAPSHOT.jar
Then build with
docker-compose up --build
I have a spring boot application which i have deployed on docker container, everything is working fine, but i want to deploy and run the application in docker container with docker compose.
This is my DockerFile
FROM java:8
VOLUME /tmp
COPY /target/order-0.0.1-SNAPSHOT.jar order.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/order.jar"]
Step 1 :- Created jar with mvn clean package
Step 2 :- docker build -t order
Step 3 :- docker run -it -d -p 8080:8080
Here everything work's fine
But if i don't execute the step 1 and want's to deploy the the application in container with docker-compose.
While trying to execute docker-compose up i am getting exception /target/order-0.0.1-SNAPSHOT.jar not found
So how to execute the mvn package command in docker-compose ?
Is their any other way's to acheive this ?
This is my docker-compose.yml
version: '3'
services:
order:
restart: always
build: ./order
working_dir: /order
volumes:
- /tmp:/logs
expose:
- "8080"
try with this one
Dockerfile
FROM maven:alpine AS build
COPY src /home/app/src
COPY pom.xml /home/app
RUN mvn -f /home/app/pom.xml clean package
FROM openjdk:alpine
COPY --from=build /home/app/target/*.jar /usr/local/lib/demo.jar
ENTRYPOINT ["java","-jar","/usr/local/lib/demo.jar"]
if you get error like Can't execute jar- file: “no main manifest attribute”
replace last command
ENTRYPOINT ["java","-cp","/usr/local/lib/demo.jar","com.packagename.classnamewithoutextension"]
I'm trying to run my Java game in Docker, but when i try to run it i get this error message
Error: Invalid or corrupt jarfile /usr/src/app/v0.0.6 - FINAL.jar
Dockerfile
# Base image
FROM java:8
#COPY . /usr/src/app
#WORKDIR /usr/src/app
# Get Code v0.0.6 from Github
ADD ["https://github.com/JohnnyDeeee/Oils-Well/blob/master/Builds/v0.0.6/v0.0.6 - FINAL.jar", "/usr/src/app/"]
# DEBUG
RUN chmod +x "/usr/src/app/v0.0.6 - FINAL.jar"
RUN ls -al /usr/src/app
# Start the Game
CMD ["java", "-jar", "/usr/src/app/v0.0.6 - FINAL.jar"]
and this is how i build
docker build -t oilswell-v0.0.6 .
and run my image
docker run oilswell-v0.0.6
This is because of the way Github serves files, currently you are pulling this exact page from Github...
https://github.com/JohnnyDeeee/Oils-Well/blob/master/Builds/v0.0.6/v0.0.6%20-%20FINAL.jar
Which if you open it, you'll see it's not your JAR, but the page showing the JAR within the GIT repository. The URL you actually need is...
https://github.com/JohnnyDeeee/Oils-Well/blob/master/Builds/v0.0.6/v0.0.6%20-%20FINAL.jar?raw=true
This will return the actual JAR, rather than the HTML page. So your Dockerfile should look like this...
# Base image
FROM java:8
ADD ["https://github.com/JohnnyDeeee/Oils-Well/blob/master/Builds/v0.0.6/v0.0.6%20-%20FINAL.jar?raw=true", "/usr/src/app/"]
RUN chmod +x "/usr/src/app/v0.0.6 - FINAL.jar"
# Start the Game
CMD ["java", "-jar", "/usr/src/app/v0.0.6 - FINAL.jar"]