0

I have a wildfly container that is running from the custom WF Image using Dockerfile. Here I have added the custom standalone-full.xml file to the config folder(/opt/jboss/wildfly/standalone/configuration) of wf and building the image accordingly. And during docker run I am not mounting the config folder as we can't able to do reverse mounting(container to host) but I need that standalone-full-app.xml file to be mounted to local.

So I tried soft link to create inside container and mount it to the respective directory, which is mounted to local during docker run command.

docker exec <wf_container> ln -s /opt/jboss/wildfly/standalone/configuration/standalone-full-app.xml /opt/jboss/wildfly/standalone/appconfig/

This directory is mounted to my local host -v /home/user/docker/app/config/:/opt/jboss/wildfly/standalone/appconfig/

I can able to read/write the soft link inside container (/opt/jboss/wildfly/standalone/appconfig/standalone-full-app.xml) and it is reflecting in actual file.

but the same file I can't able to access in my local, it says no such file or directory found.

can someone please help me to achieve accessing my standalone-full-app.xml file accessible in local?

FROM jboss/wildfly:14.0.1.Final

RUN rm /opt/jboss/wildfly/standalone/configuration/standalone.xml
RUN rm /opt/jboss/wildfly/standalone/configuration/standalone-ha.xml
RUN rm /opt/jboss/wildfly/standalone/configuration/standalone-full.xml
RUN rm /opt/jboss/wildfly/standalone/configuration/standalone-full-ha.xml

RUN rm -r /opt/jboss/wildfly/modules/system/layers/base/org/eclipse

ADD standalone.conf /opt/jboss/wildfly/bin/
ADD standalone-full-app.xml /opt/jboss/wildfly/standalone/configuration/
ADD modules /opt/jboss/wildfly/modules/
ADD startServer.sh /opt/jboss/wildfly/bin

RUN /opt/jboss/wildfly/bin/add-user.sh admin adminadmin --silent
RUN /opt/jboss/wildfly/bin/add-user.sh -a ejbuser ejbuser --silent
CMD /opt/jboss/wildfly/bin/startServer.sh -c standalone-full-app.xml -b 0.0.0.0 -bmanagement 0.0.0.0 -Djboss.management.http.port=9990 --debug
docker run --name ${WF_CONTAINER} -d -e TZ=${TIME_ZONE} \
    -v /etc/localtime:/etc/localtime:ro \
    -v /home/user/docker/app/config/:/opt/jboss/wildfly/standalone/appconfig/:rw \
    -v /home/user/docker/app/deployments:/opt/jboss/wildfly/standalone/deployments/:rw \
    -p 9990:9990 -p 8080:8080 -p 8787:8787 ${WF_IMAGE}
  • The symlink is literally just a filesystem path written to disk. Since the host and container have different filesystems, the symlink will resolve to different things; it won't get you access to the container filesystem from the host. Do you need something like [Docker: Copying files from Docker container to host](https://stackoverflow.com/questions/22049212/docker-copying-files-from-docker-container-to-host)? – David Maze Jun 10 '22 at 14:04
  • Thanks, but copied files will not sync with container file if I made some changes from host ryt? so I dont think so – lakshmi narayanan Jun 15 '22 at 04:27
  • Right, a major design goal of Docker is that the host and container have separate filesystems and changing files in one doesn't affect the other. – David Maze Jun 15 '22 at 10:00

1 Answers1

1

You used absolute path names for your softlink/symlink. But if the mount point changes, the OS can no longer follow that path.

If both source and destination for the symlink are in the same filesystem, try to create a symlink with relative path:

cd /opt/jboss/wildfly/standalone/appconfig
ln -s ../configuration/standalone-full-app.xml .

Here you have a chance the symlink resolves successfully inside and outside the container.

Queeg
  • 7,748
  • 1
  • 16
  • 42
  • Thanks, I am not creating a symlink from host. I have executed the docker exec command to get inside the container and creating a symlink from there to the mount points.. Yes I agree with your 1st point. – lakshmi narayanan Jun 15 '22 at 04:38