当docker容器中创建时,在本地无法访问软链接

发布于 2025-02-06 08:01:20 字数 2043 浏览 2 评论 0原文

我有一个使用Dockerfile从自定义WF图像运行的野生蝇容器。在这里,我已将自定义的独立full.xml文件添加到wf的配置文件夹(/opt/jboss/jboss/wildfly/standalone/configuration),并相应地构建图像。 在Docker运行期间,我没有安装配置文件夹,因为我们无法进行反向安装(容器到主机),但是我需要andalone-full-app.xml要安装到本地。

因此,我尝试了软链接以创建内部容器,并将其安装到相应的目录,该目录在Docker Run命令期间安装在本地。

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

该目录已安装到我的本地主机-v/home/user/docker/docker/app/config/:/opt/jboss/jboss/wildfly/standalone/appconfig/

我能够读取/编写软链接内部容器(/opt/jboss/wildfly/standalone/aspconfig/standalone-full-app.xml),它在实际文件中反射。

但是我无法在本地访问的同一文件,它说找不到这样的文件或目录。

有人可以帮助我实现我的独立 - full-app.xml在本地访问的文件吗?

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}

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}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

韵柒 2025-02-13 08:01:21

您为软链接/符号链接使用了绝对路径名。但是,如果安装点发生变化,则操作系统将不再遵循该路径。

如果Symlink的源和目标都位于同一文件系统中,请尝试创建一个具有相对路径的符号链接:

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

在这里您有机会在容器内外成功解决了Symlink。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文