Docker Community Forums

Share and learn in the Docker community.

Self Learning: Unable to create Jboss Image

Hi I am newbie to docker, self learning it.

I am trying to create my custom Jboss image, for which I am facing an issue.

Below is my docker file, am trying to copy specific JDK and Joss to /opt/jboss and unzip/untar the files to install Jboss and changing the /opt/jboss ownership to jboss.

Initially I have tried with ubuntu base image, but the image built was failed with below error.

FROM ubuntu
RUN mkdir /opt/jboss
COPY ./jboss-eap-7.0.0.zip /opt/jboss
COPY ./jdk-8u77-linux-x64.tar.gz /opt/jboss
RUN apt-get install -y unzip\
    && unzip /opt/jboss/jboss-eap-7.0.0.zip \
    && tar -xvf /opt/jboss/jdk-8u77-linux-x64.tar.gz\
    && useradd -aG jboss jboss \
    && chown -R jboss.jboss /opt/jboss \
    && rm jboss-eap-7.0.0.zip jdk-8u77-linux-x64.tar.gz \
CMD /bin/sh
root@ubuntu:/tmp# docker build  -t myjboss:1.0 .
ERRO[0000] Can't add file /tmp/.ICE-unix/1004 to tar: archive/tar: sockets not supported
ERRO[0000] Can't add file /tmp/.ICE-unix/1778 to tar: archive/tar: sockets not supported
ERRO[0000] Can't add file /tmp/.X11-unix/X0 to tar: archive/tar: sockets not supported
ERRO[0000] Can't add file /tmp/.X11-unix/X1024 to tar: archive/tar: sockets not supported
ERRO[0000] Can't add file /tmp/.X11-unix/X1025 to tar: archive/tar: sockets not supported
Sending build context to Docker daemon  345.4MB
Step 1/5 : FROM ubuntu
 ---> c29284518f49
Step 2/5 : RUN mkdir /opt/jboss
 ---> Using cache
 ---> c663b0fee847
Step 3/5 : COPY ./jboss-eap-7.0.0.zip /opt/jboss
 ---> Using cache
 ---> 3bb0f35e92ce
Step 4/5 : COPY ./jdk-8u77-linux-x64.tar.gz /opt/jboss
 ---> Using cache
 ---> d76aa156950f
Step 5/5 : RUN apt-get install -y unzip    && unzip /opt/jboss/jboss-eap-7.0.0.zip     && tar -xvf /opt/jboss/jdk-8u77-linux-x64.tar.gz    && useradd -aG jboss jboss     && chown -R jboss.jboss /opt/jboss     && rm jboss-eap-7.0.0.zip jdk-8u77-linux-x64.tar.gz CMD /bin/sh
 ---> Running in 092f0f167334
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package unzip
The command '/bin/sh -c apt-get install -y unzip    && unzip /opt/jboss/jboss-eap-7.0.0.zip     && tar -xvf /opt/jboss/jdk-8u77-linux-x64.tar.gz    && useradd -aG jboss jboss     && chown -R jboss.jboss /opt/jboss     && rm jboss-eap-7.0.0.zip jdk-8u77-linux-x64.tar.gz CMD /bin/sh' returned a non-zero code: 100

If i tried with alpine, it is failing at the command useradd stating command not found and returning code 127.

FROM alpine
RUN mkdir /opt/jboss
COPY ./jboss-eap-7.0.0.zip /opt/jboss
COPY ./jdk-8u77-linux-x64.tar.gz /opt/jboss
RUN apt-get install -y unzip\
    && unzip /opt/jboss/jboss-eap-7.0.0.zip \
    && tar -xvf /opt/jboss/jdk-8u77-linux-x64.tar.gz\
    && useradd -aG jboss jboss \
    && chown -R jboss.jboss /opt/jboss \
    && rm jboss-eap-7.0.0.zip jdk-8u77-linux-x64.tar.gz \
CMD /bin/sh

How I can resolve above errors to build the image.

I am unable to install unzip command to ubuntu image, so in base context I extracted the files and copy to image, now I can create base jboss image, now i want to explore more this by doing customizations.

FROM ubuntu
RUN mkdir /opt/jboss
COPY jboss-eap-7.0 /opt/jboss/jboss-eap-7.0
COPY jdk1.8.0_77 /opt/jboss/jdk1.8.0_77
RUN groupadd jboss \
    && useradd -d /home/jboss -g jboss jboss \
    && chown -R jboss.jboss /opt/jboss \
Step 1/5 : FROM ubuntu
 ---> c29284518f49
Step 2/5 : RUN mkdir /opt/jboss
 ---> Running in 057a1c2b687c
Removing intermediate container 057a1c2b687c
 ---> b1ffc459d3cd
Step 3/5 : COPY jboss-eap-7.0 /opt/jboss/jboss-eap-7.0
 ---> 7fc9e041783a
Step 4/5 : COPY jdk1.8.0_77 /opt/jboss/jdk1.8.0_77
 ---> b23098e63fc1
Step 5/5 : RUN groupadd jboss     && useradd -d /home/jboss -g jboss jboss     && chown -R jboss.jboss /opt/jboss
 ---> Running in 6487e4ffd927
Removing intermediate container 6487e4ffd927
 ---> 5ede71fba6f9
Successfully built 5ede71fba6f9
Successfully tagged myjboss:1.0

I just ran a container, but it is strange to see that the home directory for the user jboss is not created, any idea how to achieve this. I explicitly mentioned the home directory in docker file

RUN groupadd jboss
&& useradd -d /home/jboss -g jboss jboss

root@f12fb5ec8232:~# su - jboss
su: warning: cannot change directory to /home/jboss: No such file or directory

I have manually created the home directory of jboss user and .profile file, and i can apply patch to exist image by using below docker file

FROM 91ec906328fe
COPY jboss-eap-7.0.9-patch.zip /opt/jboss
RUN su - jboss -c '/opt/jboss/jboss-eap-7.0/bin/standalone.sh  &'
RUN su - jboss -c '/opt/jboss/jboss-eap-7.0/bin/jboss-cli.sh "patch apply /opt/jboss/jboss-eap-7.0.9-patch.zip"'
Step 1/5 : FROM 91ec906328fe
 ---> 91ec906328fe
Step 2/5 : COPY jboss-eap-7.0.9-patch.zip /opt/jboss
 ---> f9ed853b89a8
Step 3/5 : RUN su - jboss -c '/opt/jboss/jboss-eap-7.0/bin/standalone.sh  &'
 ---> Running in b5e110dc33d4
Removing intermediate container b5e110dc33d4
 ---> c2b861b0cae5
Step 4/5 : RUN su - jboss -c '/opt/jboss/jboss-eap-7.0/bin/jboss-cli.sh "patch apply /opt/jboss/jboss-eap-7.0.9-patch.zip"'
 ---> Running in f457d82eb096
{
    "outcome" : "success",
    "result" : {}
}
Removing intermediate container f457d82eb096
 ---> 31992c81736d
Removing intermediate container 31992c81736d
 ---> b9afb2c4e8bf
Successfully built b9afb2c4e8bf

when i run the container from the image jboss patch was applied successfully.

Nice to see you solved everything yourself. :slight_smile:

Just in case: maybe the WildFly Dockerfile can help too: wildfly/Dockerfile at master · jboss-dockerfiles/wildfly · GitHub. (But I don’t know how much EAP differs from WildFly.)

First running apt-get update will help:

FROM ubuntu
RUN apt-get update -y \
    && apt-get install -y unzip \
    && ...

Aside, using Markdown “fenced code blocks” like the following helps a lot to keep things readable (like to keep indentation, not yield curly quotes, and to not hide \ characters):

```text
your
  text "here"
```

Each EAP version ships with a specific set of fixed component versions under the hood and, if memory serves right, with some additional components.

The approach to create an EAP image should be more or less identical to create a wildfly image.

You might want to take a look of a post of mine that addresses dynamic configuration while bootstrapping the container: