将此图像与docker-compose.yml一起使用:https://hub.docker.com/_/wordpress 一切都按书上说的做,并且一切顺利,直到我尝试将一些文件夹符号链接到我的 git 存储库。
这是我的docker-compose.yml
wordpress:
image: wordpress
restart: always
ports:
- 80:80
environment:
WORDPRESS_DB_HOST: wordpressdb
WORDPRESS_DB_USER: exampleuser
WORDPRESS_DB_PASSWORD: examplepass
WORDPRESS_DB_NAME: cms_local
volumes:
- ./wordpress:/var/www/html
wp-content/plugins
我删除了文件夹中的一些插件和主题wp-content/themes
,并创建了指向我的 git 存储库的符号链接。不幸的是,Apache 无法访问它们并抛出以下错误:
AH00037: Symbolic link not allowed or link target not accessible: /var/www/html/wp-content/themes/cms-child-theme, referer: http://localhost/
当我尝试cd
从 docker 进入这些文件夹时出现以下错误:
lrwxr-xr-x 1 www-data www-data 80 Sep 19 12:25 cms-child-theme -> /Users/anatoly/Developer/example.com/wordpress/themes/cms-child-theme
-rw-rw-r-- 1 root root 28 Jun 5 2014 index.php
drwxr-xr-x 28 root root 896 Jun 29 2021 twentyfifteen
drwxr-xr-x 42 root root 1344 Jun 29 2021 twentyfourteen
drwxr-xr-x 34 root root 1088 Jun 29 2021 twentynineteen
drwxr-xr-x 25 root root 800 Jun 29 2021 twentysixteen
drwxr-xr-x 23 root root 736 Jun 29 2021 twentytwenty
drwxr-xr-x 28 root root 896 Jun 29 2021 twentytwentyone
drwxr-xr-x 12 root root 384 Feb 28 2022 twentytwentytwo
root@47205851c7e7:/var/www/html/wp-content/themes# cd cms-child-theme
bash: cd: cms-child-theme: No such file or directory
能解决吗?
答案1
符号链接在容器内解析。您可以将目录添加为附加卷
volumes:
- ./wordpress:/var/www/html
- /Users/anatoly/Developer/example.com/:/Users/anatoly/Developer/example.com/