# Image jdk, image apache

**URL:** <https://forums.docker.com/t/image-jdk-image-apache/69252>\
**Category:** Feature Requests\
**Created:** [February 15, 2019, 12:11pm UTC](https://forums.docker.com/t/image-jdk-image-apache/69252 "2019-02-15T12:11:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nsryn](https://avatars.discourse-cdn.com/v4/letter/n/e95f7d/32.png) [@nsryn](https://forums.docker.com/u/nsryn)\
**Post date:** [February 15, 2019, 12:11pm UTC](https://forums.docker.com/t/image-jdk-image-apache/69252/1 "2019-02-15T12:11:11Z")

</div>

hello,  
i want to know the easy way to install the apache and the jdk8 in docker.  
thanks

---

<div class="post-metadata">

**Author:** ![ovelindstrom](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/ovelindstrom/32/18494_2.png) [@ovelindstrom](https://forums.docker.com/u/ovelindstrom)\
**Post date:** [February 15, 2019, 12:32pm UTC](https://forums.docker.com/t/image-jdk-image-apache/69252/2 "2019-02-15T12:32:29Z")

</div>

Use the official images.

When you say “apache” I make an assumption that you are talking about httpd. ([https://hub.docker.com/\_/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](https://hub.docker.com/_/openjdk)).

---

<div class="post-metadata">

**Author:** ![gforghetti](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/gforghetti/32/22570_2.png) [@gforghetti](https://forums.docker.com/u/gforghetti)\
**Post date:** [February 15, 2019, 2:10pm UTC](https://forums.docker.com/t/image-jdk-image-apache/69252/3 "2019-02-15T14:10:36Z")

</div>

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

```bash
🐳 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

```bash
🐳 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

```bash
🐳 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

```bash
🐳 gforghetti:[~/Downloads] $ curl 127.0.0.1
<html><body><h1>It works!</h1></body></html>

```

Check to see if Java is installed and working.

```bash
🐳 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)

```
