i want to build a minecraft spigot minecraft server with docker.
So i get in touch with docker and i dont think i get the entire hang of it.
When i run the image as a cotainer i get:
Recreating minecraft-spigot-1165x86_64_mc_1 ... done
Attaching to minecraft-spigot-1165x86_64_mc_1
mc_1 | Error: Unable to access jarfile spigot.jar
minecraft-spigot-1165x86_64_mc_1 exited with code 1
I dont know why it cant start the jar file. I already tried using "Entrypoint" and "CMD". Both dosent work :/. I added "RUN ls" so i can see if its copied, and yes its showing the file when i build the image. pls help :)
Used Dockerfile
FROM ubuntu:latest
LABEL maintainer="CruZer606#private"
RUN apt-get update && apt-get upgrade -y
RUN apt install default-jdk -y
RUN mkdir /srv/minecraft && cd /srv/minecraft
COPY spigot.jar /srv/minecraft/spigot.jar
WORKDIR /srv/minecraft
RUN ls -al
RUN echo "eula = true" > /srv/minecraft/eula.txt
EXPOSE 25565
ENTRYPOINT ["java", "-Xms4096M", "-Xmx4096M", "-jar", "spigot.jar"]
Related
I'm fairly new to Docker and am struggling with JAVA_HOME not being seen in a Dockerfile. I get the titular error; which includes Please set the JAVA_HOME variable in your environment to match the location of your Java installation. & executor failed running [/bin/sh -c /opt/Android/cmdline-tools/latest/bin/sdkmanager --update]: exit code: 1 when it runs RUN /opt/Android/cmdline-tools/latest/bin/sdkmanager --update.
I feel like I'm at a loss but I think my issue is not knowing where the JDK is being installed to or knowing how to find it from a Dockerfile; I've tried echoing JAVA_HOME thinking I could see it while the image built but, again, no luck. Any help with this would be greatly appreciated. I've been pulling my hair out Googling & trying things. Thank you.
FROM node:12.12.0
ARG CMDLINE_TOOLS_VERSION=7583922
ARG ANDROID_BUILD_TOOLS=30.0.3
RUN apt-get -qqy update \
&& apt-get -qqy install \
python-dev \
--no-install-recommends
RUN apt-get install -y software-properties-common gcc
RUN apt-get update && apt-get install -y python3-pip
RUN pip3 install awscli
RUN apt-get install -y jq
RUN mkdir -p /usr/share/man/man1 /usr/share/man/man2
RUN apt-get update && apt-get install -y --no-install-recommends openjdk-8-jdk && apt-get clean;
ENV JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
ENV PATH=$PATH:$JAVA_HOME/bin
RUN wget -q https://services.gradle.org/distributions/gradle-4.5.1-bin.zip && unzip gradle-4.5.1-bin.zip -d /opt && rm gradle-4.5.1-bin.zip
ENV GRADLE_HOME=/opt/gradle-4.5.1
ENV PATH=$PATH:/opt/gradle-4.5.1/bin
RUN wget https://dl.google.com/android/repository/commandlinetools-linux-${CMDLINE_TOOLS_VERSION}_latest.zip
RUN mkdir -p /opt/Android/cmdline-tools
RUN unzip commandlinetools-linux-7583922_latest.zip -d /opt/Android/cmdline-tools
RUN mv /opt/Android/cmdline-tools/cmdline-tools /opt/Android/cmdline-tools/latest
ENV ANDROID_HOME=/opt/Android
ENV PATH="$ANDROID_HOME/emulator:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin \
:$ANDROID_HOME/cmdline-tools/latest:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools:$PATH"
RUN /opt/Android/cmdline-tools/latest/bin/sdkmanager --update
RUN /opt/Android/cmdline-tools/latest/bin/sdkmanager --list
RUN /opt/Android/cmdline-tools/latest/bin/sdkmanager --list | grep build-tools
RUN echo y | /opt/Android/cmdline-tools/latest/bin/sdkmanager "build-tools;${ANDROID_BUILD_TOOLS}" "platform-tools" "platforms;android-30" "tools" >/dev/null
RUN yes | /opt/Android/cmdline-tools/latest/bin/sdkmanager --licenses
CMD ["yarn", "start"]
I'd suggest to use another base image. Java 11 is required to build for newer API levels:
FROM openjdk:11-jdk as builder
...
And then install Python3 and AWS CLI.
Working example: cloudbuild-android.
Or if you want to continue with your's, RUN which java would tell you where it's actually installed.
In a comment, you mentioned:
when I run [RUN ls -lart /usr/lib/jvm/java-8-openjdk-amd64], I get cannot access '/usr/lib/jvm/java-8-openjdk-amd64': No such file or directory
Maybe I'm missing something, but... doesn't that mean that the directory does not exist?
Either you got the path wrong, or (as another answer suggested) there's something in your Dockerfile, probably line endings, that's mangling your lines.
To discard the bit about line endings, try the same command but switching the parameters, i.e.:
RUN ls /usr/lib/jvm/java-8-openjdk-amd64 -lart
If now it whines about unrecognized options, then it's probably a line ending issue (which now affects the t option instead of the directory path).
However, if it still says No such file or directory, then you definitely should check your Java installation path.
I think your problem is in the line termination characters of your Dockerfile.
Your Dockerfile works in my computer, and when it comes to weird errors, I have been there.
My experience with Dockerfiles is that sometimes they are very picky in the Windows/Unix/Mac line terminators, so please make sure you save the Dockerfile with line terminators adequate for Unix machines.
I have used the method in this other answer to successfully replace Windows line terminators for Unix's on Windows using Powershell. I hope this helps!
The exact location of $JAVA_HOME can be scripted. If you don't feel like hardcoding that directory is a safe bet, replace your ENV line with this RUN: RUN export JAVA_HOME=$(readlink -f $(which java) | sed "s:/bin/java::"). This is how I set up my environment in all my Linux machines, and what it does is the following:
which java searches for java and will output /usr/bin/java, or something like that, which is a symbolic link.
readlink -f over the above will get you to the destination of the symbolic link.
piping such destination over to | sed "s:/bin/java::" will strip the trailing bin/java and get you the right value, no matter the version.
I also tried your Dockerfile with this change, and it does work too.
It looks like you had some network issues during your first docker build run. It failed to install java, but cached the layer with the attempt. I recommend you to run your build again without caching: docker build -t name --no-cache . and check logging of network operations.
I am trying to start a Java program in a docker container. After docker-compose build i try to start the program with docker-compose up but get the following error:
Exception in thread "main" java.lang.UnsupportedOperationException: Unable to open DISPLAY
The readme of the progam says:
"If you get the error message that the container cannot connect to Xorg (Unable to open DISPLAY) when starting the container, the supplied script "./startup.sh" needs to be executed".
startup.sh:
#!/bin/sh
xhost +local:
docker-compose up
xhost -local:
dockerfile
FROM ubuntu:16.04
RUN apt-get update && apt-get install --assume-yes --no-install-recommends openjfx openjdk-8-jdk maven git
COPY . /opt/Testfolder
WORKDIR /opt/Testfolder/src
RUN mvn package -DskipTests -Dcheckstyle.skip
CMD java -jar program.jar
At what point would i need to execute the startup.sh script? Do i need to add another RUN startup.sh in the dockerfile? Anyone has an idea?
I am new to docker and trying to install tomcat on top of ubuntu using a Dockerfile.
but getting error building an image from the Dockerfile.
Error saying...
Sending build context to Docker daemon 12.8kB
Step 1/12 : FROM ubuntu:latest
---> d13c942271d6
Step 2/12 : MAINTAINER xyz
---> Using cache
---> 83dbc04930a4
Step 3/12 : RUN mkdir /opt/tomcat/
---> Using cache
---> 1e167fd46a0e
Step 4/12 : WORKDIR /opt/tomcat/
---> Using cache
---> 26c7316b8e12
Step 5/12 : RUN apt-get update && apt-get install -y curl
---> Using cache
---> b0138decc33d
Step 6/12 : RUN curl -O https://www-eu.apache.org/dist/tomcat/tomcat-8/v8.5.50/bin/apache-tomcat-8.5.50.tar.gz
---> Using cache
---> eda41a539c78
Step 7/12 : RUN tar -xvzf apache-tomcat-8.5.50.tar.gz
---> Running in cc9f646b2bb2
gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now
The command '/bin/sh -c tar -xvzf apache-tomcat-8.5.50.tar.gz' returned a non-zero code: 2
and my code is
FROM ubuntu: latest
MAINTAINER ganeshthirumani
RUN mkdir /opt/tomcat/
WORKDIR /opt/tomcat/
RUN apt-get update && apt-get install -y curl
RUN curl -O https://www-eu.apache.org/dist/tomcat/tomcat-8/v8.5.50/bin/apache-tomcat-8.5.50.tar.gz
RUN tar -xvzf apache-tomcat-8.5.50.tar.gz
RUN mv apache-tomcat-8.5.50/* /opt/tomcat/.
WORKDIR /opt/docker-tomcat/tomcat/webapps
RUN curl -O -L https://github.com/AKSarav/SampleWebApp/raw/master/dist/SampleWebApp.war
EXPOSE 3000
CMD ["/opt/tomcat/bin/catalina.sh", "run"]
I am trying to understand the code as it was suggested by one of my friends,
as my understanding:
at line
fixing the base image as ubuntu
this is the metadata of the person who is maintaining the code, it may be organizational
3,4. working directory, here we have two working directories, one to run docker commands and another is to deploy the war file
is to install the curl on docker
6-10. I did not understand anything.
is to make the localhost to run the tomcat
cmd to run the container
I am trying but I was not able to what It means...
it would be helpful if anyone respond...
Thank you so much...
Build docker images using docker file for maven project
When try running docker run getting error saying Unable to access jarfile.
Can some one assist on whats wrong with .
FROM openjdk:8-jre-alpine as release
RUN addgroup -g 1001 -S user1 && user1 -u 1001 -S user1 -G user1
WORKDIR /home/app
COPY --from=builder /home/app/service-1.0.0.jar .
RUN chown -R user1:user1 /home/app
USER user1
ENTRYPOINT ["java", "-jar" ,"/home/app/service-1.0.0.jar"]
but when i go for docker run with local config files as build mount
docker run -it --mount type=bind,source=D:/Java/service/docker/config,target=/home/app services
Unable to access jarfile /home/app/service-1.0.0.jar
Can someone assist on this or is something wrong i did??
I am not sure if you are looking for multistage docker build. If not, you need not use "COPY --from=builder" as it tires to copy the build artifact from your previous stage to this new stage. If it is a single stage docker build, you might just use the copy as follows -
COPY /home/app/service-1.0.0.jar .
Able to resolve the same, Issue was due to mound of config files not happened properly.
instead of docker run -it --mount type=bind,source=D:/Java/service/docker/config,target=/home/app services changes it to docker run -it --mount type=bind,source=D:/Java/service/docker/config/app.config,target=/home/app services which made service to load and work
I am trying to run a Kafka Streams application in kubernetes. When I launch the pod I get the following exception:
Exception in thread "streams-pipe-e19c2d9a-d403-4944-8d26-0ef27ed5c057-StreamThread-1"
java.lang.UnsatisfiedLinkError: /tmp/snappy-1.1.4-5cec5405-2ce7-4046-a8bd-922ce96534a0-libsnappyjava.so:
Error loading shared library ld-linux-x86-64.so.2: No such file or directory
(needed by /tmp/snappy-1.1.4-5cec5405-2ce7-4046-a8bd-922ce96534a0-libsnappyjava.so)
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1824)
at java.lang.Runtime.load0(Runtime.java:809)
at java.lang.System.load(System.java:1086)
at org.xerial.snappy.SnappyLoader.loadNativeLibrary(SnappyLoader.java:179)
at org.xerial.snappy.SnappyLoader.loadSnappyApi(SnappyLoader.java:154)
at org.xerial.snappy.Snappy.<clinit>(Snappy.java:47)
at org.xerial.snappy.SnappyInputStream.hasNextChunk(SnappyInputStream.java:435)
at org.xerial.snappy.SnappyInputStream.read(SnappyInputStream.java:466)
at java.io.DataInputStream.readByte(DataInputStream.java:265)
at org.apache.kafka.common.utils.ByteUtils.readVarint(ByteUtils.java:168)
at org.apache.kafka.common.record.DefaultRecord.readFrom(DefaultRecord.java:292)
at org.apache.kafka.common.record.DefaultRecordBatch$1.readNext(DefaultRecordBatch.java:264)
at org.apache.kafka.common.record.DefaultRecordBatch$RecordIterator.next(DefaultRecordBatch.java:563)
at org.apache.kafka.common.record.DefaultRecordBatch$RecordIterator.next(DefaultRecordBatch.java:532)
at org.apache.kafka.clients.consumer.internals.Fetcher$PartitionRecords.nextFetchedRecord(Fetcher.java:1060)
at org.apache.kafka.clients.consumer.internals.Fetcher$PartitionRecords.fetchRecords(Fetcher.java:1095)
at org.apache.kafka.clients.consumer.internals.Fetcher$PartitionRecords.access$1200(Fetcher.java:949)
at org.apache.kafka.clients.consumer.internals.Fetcher.fetchRecords(Fetcher.java:570)
at org.apache.kafka.clients.consumer.internals.Fetcher.fetchedRecords(Fetcher.java:531)
at org.apache.kafka.clients.consumer.KafkaConsumer.pollOnce(KafkaConsumer.java:1146)
at org.apache.kafka.clients.consumer.KafkaConsumer.poll(KafkaConsumer.java:1103)
at org.apache.kafka.streams.processor.internals.StreamThread.pollRequests(StreamThread.java:851)
at org.apache.kafka.streams.processor.internals.StreamThread.runOnce(StreamThread.java:808)
at org.apache.kafka.streams.processor.internals.StreamThread.runLoop(StreamThread.java:774)
at org.apache.kafka.streams.processor.internals.StreamThread.run(StreamThread.java:744)
Previously I have tried launching kafka and kafka-streams-app using docker containers and they worked perfectly fine. This is the first time I am trying with Kubernetes.
This is my DockerFile StreamsApp:
FROM openjdk:8u151-jdk-alpine3.7
COPY /target/streams-examples-0.1.jar /streamsApp/
COPY /target/libs /streamsApp/libs
CMD ["java", "-jar", "/streamsApp/streams-examples-0.1.jar"]
What can I do to get past this issue? Kindly help me out.
EDIT:
/ # ldd /usr/bin/java
/lib/ld-musl-x86_64.so.1 (0x7f03f279a000)
Error loading shared library libjli.so: No such file or directory (needed by /usr/bin/java)
libc.musl-x86_64.so.1 => /lib/ld-musl-x86_64.so.1 (0x7f03f279a000)
Error relocating /usr/bin/java: JLI_Launch: symbol not found
In my case, install the missing libc6-compat didn't work. Application still throw java.lang.UnsatisfiedLinkError.
Then I find in the docker, /lib64/ld-linux-x86-64.so.2 exist and is a link to /lib/libc.musl-x86_64.so.1, but /lib only contains ld-musl-x86_64.so.1, not ld-linux-x86-64.so.2.
So I add a file named ld-linux-x86-64.so.2 linked to ld-musl-x86_64.so.1 in /lib dir and solve the problem.
Dockerfile I use:
FROM openjdk:8-jre-alpine
COPY entrypoint.sh /entrypoint.sh
RUN apk update && \
apk add --no-cache libc6-compat && \
ln -s /lib/libc.musl-x86_64.so.1 /lib/ld-linux-x86-64.so.2 && \
mkdir /app && \
chmod a+x /entrypoint.sh
COPY build/libs/*.jar /app
ENTRYPOINT ["/entrypoint.sh"]
In conclusion:
RUN apk update && apk add --no-cache libc6-compat
ln -s /lib/libc.musl-x86_64.so.1 /lib/ld-linux-x86-64.so.2
Error message states that *libsnappyjava.so cannot find ld-linux-x86-64.so.2. This is a glibc dynamic loader, while Alpine image doesn't run with glibc. You may try to get it running by installing libc6-compat package in your Dockerfile, e.g.:
RUN apk update && apk add --no-cache libc6-compat
There are two solutions of this problem:
You may use some other base image with pre-installed snappy-java lib. For example openjdk:8-jre-slim works fine for me
And the other solution is to still use openjdk:8-jdk-alpine image as base one, but then install snappy-java lib manually:
FROM openjdk:8-jdk-alpine
RUN apk update && apk add --no-cache gcompat
...
in docker with alpine kernel
run apk update && apk add --no-cache libc6-compat gcompat
save my life
If you are adding docker file through build.sbt then correct way to do it is
dockerfile in docker := {
val artifact: File = assembly.value
val artifactTargetPath = s"/app/${artifact.name}"
new Dockerfile {
from("openjdk:8-jre-alpine")
copy(artifact, artifactTargetPath)
run("apk", "add", "--no-cache", "gcompat")
entryPoint("java", "-jar", artifactTargetPath)
}
installing gcompat will serve your purpose
It seems strange, but looks like the docker image you use- openjdk:8u151-jdk-alpine3.7 is inconsistent, and
some dynamically loaded objects are not included into the package, or you need to run “ldconfig -v” in this image to update
map of the shared objects, or, at last, there is /etc/ld.so.conf with the paths to places where OS is looking for .so objects.
Please consider using another docker image providing java binary if you do not want to lose time on debugging it. Last but not least, ask for a remedy on alpine forum.
I have implemented a docker image with which I run a Spring Boot microservice with a Kafka Strean Topology working perfectly.
Here I share the Dockerfile file.
FROM openjdk:8-jdk-alpine
# Add Maintainer Info
LABEL description="Spring Boot Kafka Stream IoT Processor"
# Args for image
ARG PORT=8080
RUN apk update && apk upgrade && apk add --no-cache gcompat
RUN ln -s /bin/bash /usr/bin
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY resources/wait-for-it.sh wait-for-it.sh
COPY target/iot_processor.jar app.jar
RUN dos2unix wait-for-it.sh
RUN chmod +x wait-for-it.sh
RUN uname -a
RUN pwd
RUN ls -al
EXPOSE ${PORT}
CMD ["sh", "-c", "echo 'waiting for 300 seconds for kafka:9092 to be accessable before
starting application' && ./wait-for-it.sh -t 300 kafka:9092 -- java -jar app.jar"]
Hope it can help someone
I don't need to add libc6-compat in dockerFile
Because the file /lib/libc.musl-x86_64.so.1 exist in my container
In dockerFile add only
run ln -s /lib/libc.musl-x86_64.so.1 /lib/ld-linux-x86-64.so.2
My container don't have error when consumming msg on snappy compressing
Exception in thread "streams-pipe-e19c2d9a-d403-4944-8d26-0ef27ed5c057-StreamThread-1"
java.lang.UnsatisfiedLinkError: /tmp/snappy-1.1.4-5cec5405-2ce7-4046-a8bd-
922ce96534a0-libsnappyjava.so:
Error loading shared library ld-linux-x86-64.so.2: No such file or directory
(needed by /tmp/snappy-1.1.4-5cec5405-2ce7-4046-a8bd-922ce96534a0-libsnappyjava.so)
at java.lang.ClassLoader$NativeLibrary.load(Native Method)