hello,
i want to know the easy way to install the apache and the jdk8 in docker.
thanks
Use the official images.
When you say “apache” I make an assumption that you are talking about httpd. (https://hub.docker.com/_/httpd)
A JDK is found at OpenJDK. Many other manufacturers also have their own docker images for their JRE and JDKs. (https://hub.docker.com/_/openjdk).
Hi.
You have not given any details on what you are trying to do or what Docker platform or container platform.
If you want both OpenJDK 8 and Apache on the same docker image you need to build a custom image.
Example
My Dockerfile
🐳 gforghetti:[~/Downloads] $ cat Dockerfile
FROM httpd:latest
RUN apt-get update -qq && \
mkdir -p /usr/share/man/man1 && \
apt-get install default-jre default-jdk -y && \
update-alternatives --config java && \
update-alternatives --config javac && \
/var/lib/dpkg/info/ca-certificates-java.postinst configure && \
echo '*********' && \
update-ca-certificates -f
Build the custom image
🐳 gforghetti:[~/Downloads] $ docker image build -t apache-jdk:latest .
Sending build context to Docker daemon 12.8kB
Step 1/2 : FROM httpd:latest
latest: Pulling from library/httpd
6ae821421a7d: Pull complete
0ceda4df88c8: Pull complete
24f08eb4db68: Pull complete
ddf4fc318081: Pull complete
fc5812428ac0: Pull complete
Digest: sha256:5e7992fcdaa214d5e88c4dfde274befe60d5d5b232717862856012bf5ce31086
Status: Downloaded newer image for httpd:latest
---> d3a13ec4a0f1
Step 2/2 : RUN apt-get update -qq && mkdir -p /usr/share/man/man1 && apt-get install default-jre default-jdk -y && update-alternatives --config java && update-alternatives --config javac && /var/lib/dpkg/info/ca-certificates-java.postinst configure && echo '*********' && update-ca-certificates -f
---> Running in 7975994c82cf
Reading package lists...
Building dependency tree...
Reading state information...
******* suppressed some output ********
Removing intermediate container 7975994c82cf
---> 9add500734c5
Successfully built 9add500734c5
Successfully tagged apache-jdk:latest
Bring up a container from the custom docker image
🐳 gforghetti:[~/Downloads] $ docker container run --detach --name apache --publish 80:80 apache-jdk:latest
aacbf3c08c838d418241f476ee46b9ac507efc65d3f25ea0b7bf88bb31ad45c0
Check to see if apache is running and listening on port 80
🐳 gforghetti:[~/Downloads] $ curl 127.0.0.1
<html><body><h1>It works!</h1></body></html>
Check to see if Java is installed and working.
🐳 gforghetti:[~/Downloads] $ docker container exec -it apache java -version
openjdk version "1.8.0_181"
OpenJDK Runtime Environment (build 1.8.0_181-8u181-b13-2~deb9u1-b13)
OpenJDK 64-Bit Server VM (build 25.181-b13, mixed mode)