I am developing an application using SpringBoot and Java with Docker.
I want to install Netcat in my application so that I can check if a specific container is up before my spring application starts.
I have tried
RUN apt-get update && apt-get -y install netcat && apt-get clean
But it says apt-get is not found.
I am not sure how can I install any package manager in my java based application.
Or is there any other I can get net-cat installed.
Below is my Dockerfile
FROM openjdk:8
RUN apt-get update && apt-get -y install netcat && apt-get clean
ADD target/student.jar student.jar
EXPOSE 2018
ENTRYPOINT ["java","-jar","student.jar"]
apt-get
is package manager for Debian-based Linux distros (including Ubuntu and others).
Try apk add
instead.
Also, if you are using package managers in your Dockerfile
, it is considered a good practice to explicitly specify Linux distro. In your case you can use openjdk:8-jdk-stretch
variant or any other, where distro is specified.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With