I've a problem when I clear the cache in a Vagrant VM. Here a part of the config file :
synced_folder:
vflsf_19mkvk0x71hk:
source: /var/www/vm/vmnginx
target: /var/www
sync_type: default
smb:
smb_host: ''
smb_username: ''
smb_password: ''
mount_options:
dir_mode: '0775'
file_mode: '0664'
rsync:
args:
- '--verbose'
- '--archive'
- '-z'
exclude:
- .vagrant/
- .git/
- vendor/
auto: 'true'
owner: vagrant
group: www-data
The error message tell me it can't be possible to remove a folder :
$ sfconsole cache:clear -vv
22:46:17 INFO [php] User Deprecated: The "Symfony\Component\Console\Event\ConsoleExceptionEvent" class is deprecated since version 3.3 and will be removed in 4.0. Use the ConsoleErrorEvent instead. ["exception" => Symfony\Component\Debug\Exception\ContextErrorException {trace: { …} …}] []
[Symfony\Component\Filesystem\Exception\IOException]
Failed to remove directory "/var/www/formation/symfony-blog/var/cache/de~/translations": .
Exception trace:
() at /var/www/formation/symfony-blog/vendor/symfony/symfony/src/Symfony/Component/Filesystem/Filesystem.php:176
Symfony\Component\Filesystem\Filesystem->remove() at /var/www/formation/symfony-blog/vendor/symfony/symfony/src/Symfony/Component/Filesystem/Filesystem.php:172
Symfony\Component\Filesystem\Filesystem->remove() at /var/www/formation/symfony-blog/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php:70
Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand->execute() at /var/www/formation/symfony-blog/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php:264
Symfony\Component\Console\Command\Command->run() at /var/www/formation/symfony-blog/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:887
Symfony\Component\Console\Application->doRunCommand() at /var/www/formation/symfony-blog/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:223
Symfony\Component\Console\Application->doRun() at /var/www/formation/symfony-blog/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:81
Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /var/www/formation/symfony-blog/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:130
Symfony\Component\Console\Application->run() at /var/www/formation/symfony-blog/bin/console:28
cache:clear [--no-warmup] [--no-optional-warmers] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command>
I've add the "vagrant" user in the "www-data" group.
Folder :
$ ll var/cache/
total 16K
drwxrwxr-x 1 vagrant www-data 4,0K juil. 8 22:43 ./
drwxrwxr-x 1 vagrant www-data 4,0K juil. 7 16:01 ../
drwxrwxr-x 1 vagrant www-data 4,0K juil. 8 22:43 de~/
drwxrwxr-x 1 vagrant www-data 4,0K juil. 8 22:43 dev/
Here the "real" folder outside the VM :
✔ /var/www/vm/vmnginx/formation/symfony-blog [master {origin/master}|✚ 9]
11:10 $ ll var/cache/
total 16K
drwxrwxr-x 4 fabrice fabrice 4,0K juil. 9 09:56 ./
drwxrwxr-x 5 fabrice fabrice 4,0K juil. 7 16:01 ../
drwxrwxr-x 3 fabrice fabrice 4,0K juil. 9 09:56 de~/
drwxrwxr-x 7 fabrice fabrice 4,0K juil. 9 09:56 dev/
And, I can't change the permissions, even in with sudo. There's no error message, but nothing happend.
The "rm -fr var/cache" works.
Can u help me please.
Fabrice
In must case this is drasticaly the last treatment, but its work. Have a look there :
https://symfony.com/doc/current/setup/file_permissions.html#using-acl-on-a-system-that-supports-setfacl-linux-bsd
$ ll var/cache/de~
total 1,3M
drwxrwxr-x 1 vagrant www-data 4,0K juil. 9 09:56 ./
drwxrwxr-x 1 vagrant www-data 4,0K juil. 9 09:56 ../
-rwxrwxr-- 1 vagrant www-data 130K juil. 8 22:43 appDevDebugProjectContainerCompiler.log*
-rwxrwxr-- 1 vagrant www-data 459K juil. 9 09:56 appDevDebugProjectContainer.php*
-rwxrwxr-- 1 vagrant www-data 26K juil. 9 09:56 appDevDebugProjectContainer.php.meta*
-rwxrwxr-- 1 vagrant www-data 365K juil. 8 22:43 appDevDebugProjectContainer.xml*
-rwxrwxr-- 1 vagrant www-data 314K juil. 8 22:43 classes.php*
drwxrwxr-x 1 vagrant www-data 4,0K juil. 9 09:56 pools/
and
$ ll var/cache/de~/pools/
total 8,0K
drwxrwxr-x 1 vagrant www-data 4,0K juil. 9 09:56 ./
drwxrwxr-x 1 vagrant www-data 4,0K juil. 9 09:56 ../
Related
I've started to play with R, and wanted to build a simple custom image. When attempting to launch a new container with the r-base official image, using the instructions provided, it fails.
$ docker run -ti --rm r-base
ERROR: R_HOME ('/usr/lib/R') not found
I'm running Debian 10, on WSL2:
$ uname -r
5.4.72-microsoft-standard-WSL2
$ lsb_release -a
Distributor ID: Debian
Description: Debian GNU/Linux 10 (buster)
Release: 10
Codename: buster
$ docker --version
Docker version 18.09.1, build 4c52b90
Launching a container with bash, there are files in the mentioned lib directory:
$ docker run -ti --rm r-base /bin/bash
root#f27f0139a6be:/# ls -l /usr/lib/R/
total 28
drwxr-xr-x 3 root root 4096 Jul 12 13:23 bin
lrwxrwxrwx 1 root root 33 Jun 23 10:26 COPYING -> ../../share/common-licenses/GPL-2
drwxr-xr-x 2 root root 4096 Jul 12 13:23 etc
drwxr-xr-x 2 root root 4096 Jul 12 13:23 lib
drwxr-xr-x 32 root root 4096 Jul 12 13:23 library
drwxr-xr-x 2 root root 4096 Jul 12 13:23 modules
drwxr-xr-x 4 root root 4096 Jul 12 13:23 site-library
-rw-r--r-- 1 root root 46 Jun 23 10:26 SVN-REVISION
root#f27f0139a6be:/# R
ERROR: R_HOME ('/usr/lib/R') not found
I've played around with a few different recent tags/versions of the image, but same issue. Is this some incompatibility with WSL2? Am I missing an environment variable?
I am planning to use Wordpress official docker image on Amazon ECS. The problem is that instead working on the root path https://www.example.com/, I need it to work on a subdirectory path https://www.example.com/blog/.
To modify this I am planning to create a new Docker image based on the official Wordpress docker image.
My current Dockerfile looks like this.
FROM wordpress:6.0.1-apache
# Copying to premium so user can access it through
# domain/blog
RUN cd /var/www/html; \
mkdir blog; \
cp !\(blog\) blog; \
# We copy the wordpress instance to subdirectory and disable
# access to the root instance.
echo "Hello World!" > /var/www/html/index.php;
However this doesn't work. When I access https://www.example.com/blog it shows Forbidden.
The log shows this
[autoindex:error] [pid 23] [client 172.30.0.1:61822] AH01276: Cannot serve directory /var/www/html/blog/: No matching DirectoryIndex (index.php,index.html) found, and server-generated directory index forbidden by Options directive
It seems that the image does not copy the wordpress library.
wordpress % docker compose exec wordpress bash
root#63d417de7f31:/var/www/html# ls
index.php blog wp-config.php wp-content
root#63d417de7f31:/var/www/html# ls -al
total 32
drwxrwxrwx 4 www-data www-data 4096 Aug 5 06:13 .
drwxr-xr-x 1 root root 4096 Aug 2 07:49 ..
-rw-r--r-- 1 root root 13 Aug 5 06:06 index.php
drwxr-xr-x 2 root root 4096 Aug 5 06:06 blog
-rw-r--r-- 1 www-data www-data 5584 Aug 5 06:13 wp-config.php
drwxrwxrwx 5 www-data www-data 4096 Aug 5 06:13 wp-content
root#63d417de7f31:/var/www/html# ls -al blog/
total 8
drwxr-xr-x 2 root root 4096 Aug 5 06:06 .
drwxrwxrwx 4 www-data www-data 4096 Aug 5 06:13 ..
root#63d417de7f31:/var/www/html# exit
What should I do?
Update 1
When I trim the Dockerfile to just the base image like this,
FROM wordpress:6.0.1-apache
the wordpress files are copied into /var/www/html.
% docker compose exec wordpress bash
root#f9ad22323268:/var/www/html# ls
index.php wp-admin wp-config-sample.php wp-includes wp-mail.php xmlrpc.php
license.txt wp-blog-header.php wp-config.php wp-links-opml.php wp-settings.php
readme.html wp-comments-post.php wp-content wp-load.php wp-signup.php
wp-activate.php wp-config-docker.php wp-cron.php wp-login.php wp-trackback.php
Update 2
I tried using this
FROM wordpress:6.0.1-apache
WORKDIR /var/www/html/blog
This copies the Wordpress installation both in /var/www/html and /var/www/html/blog. This still fits the requirement, however I want to remove the one in /var/www/html/. I tried rewriting to /var/www/html/index.php like below
FROM wordpress:6.0.1-apache
WORKDIR /var/www/html/blog
RUN echo "Hello World!" > /var/www/html/index.php
But it's not rewritten. Seems like it's being rewritten from the entrypoint
https://github.com/docker-library/wordpress/blob/master/docker-entrypoint.sh
Give Apache user access to blog directory. By adding following to Dockerfile
RUN chown -R www-data:www-data /var/www/html/blog
I'm trying to change the user: root to www-data in Dockerfile to build wordpress image. Once I run the dockerfile and go inside the image: the permission is not changed.
This is my Dockerfile:
FROM wordpress:php7.1-apache
COPY . /var/www/html
WORKDIR /var/www/html
RUN chown -R www-data:www-data /var/www/html/
RUN chmod -R 777 /var/www/html
This is the result in the image by running that Dockerfie:
root#081507c3824e:/var/www/html# ls -lh
total 228K
-rw-r--r-- 1 root root 149 Jul 5 05:09 Dockerfile
-rw-r--r-- 1 root root 405 Jul 5 05:09 index.php
-rw-r--r-- 1 root root 20K Jul 5 05:09 license.txt
-rw-r--r-- 1 root root 7.2K Jul 5 05:09 readme.html
drwxr-xr-x 9 root root 4.0K Jul 5 05:15 wp-admin
-rw-r--r-- 1 root root 351 Jul 5 05:09 wp-blog-header.php
/var/www/html is marked a VOLUME in Dockerfile of wordpress. Your RUN instruction won't persist after the build.
You can try any of the following approaches if you want to change the permisions of /var/www/html/ directory.
You can mount a directory with modified permissions from host machine into the container.
You can create an entrypoint script which changes the permission of the directory before starting the main process.
This only happens with docker inside minikube
operating on host using minikube docker eval (minikube docker-env)
Trying to build a basic setup with Nginx serving a single file:
conf.d/example.conf
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
server_name localhost;
location /file.json { root /data/; }
}
data/file.json
{"a": 1}
Run using docker nginx image:
docker run -it --rm -v "$(PWD)/conf.d:/etc/nginx/conf.d":ro -v "$(PWD)/data:/data":ro -p 8085:80 nginx
curl http://localhost/file.json gives me 2017/02/01 19:07:39 [error] 6#6: *1 open() "/data/file.json" failed (13: Permission denied)...
Cannot figure out how to make this right... Help wanted!
What I've tried so far:
providing a custom command like chmod -R o+x /data && ls -la data && nginx -g "daemon off;"
-rwxrwx--- 1 root 1013 11 Feb 1 13:08 /data/file.json
chmod does not seem to work properly.
neither chown :(
$ docker run -it --rm -v "$(PWD):/etc/nginx/conf.d":ro -v "$(PWD)/data:/data" -p 8085:80 nginx bash -c 'chown -R nginx:nginx /data/ && ls -la /data/ && nginx -g daemon off;"'
total 8
drwxrwx--- 1 root 1013 102 Feb 1 13:08 .
drwxr-xr-x 1 root root 4096 Feb 1 19:50 ..
-rwxrwx--- 1 root 1013 11 Feb 1 13:08 pub_key.json
setting a docker user to nginx
chmod -R 777 data on host
$ ls -la data
drwxrwxrwx 3 antonk staff 102 Feb 1 17:08 data
$ docker run -it --rm -v "$(PWD):/etc/nginx/conf.d":ro -v "$(PWD)/data:/data" -p 8085:80 nginx bash -c 'ls -la /data/ && nginx -g "daemon off;"'
total 8
drwxrwx--- 1 root 1013 102 Feb 1 13:08 .
drwxr-xr-x 1 root root 4096 Feb 1 20:20 ..
-rwxrwx--- 1 root 1013 11 Feb 1 13:08 pub_key.json
$ docker version
Client:
Version: 1.13.1-rc1
API version: 1.23
Go version: go1.7.4
Git commit: 2527cfc
Built: Sat Jan 28 00:43:00 2017
OS/Arch: darwin/amd64
Server:
Version: 1.11.1
API version: 1.23 (minimum version )
Go version: go1.5.4
Git commit: 5604cbe
Built: Wed Apr 27 00:34:20 2016
OS/Arch: linux/amd64
Experimental: false
minikube version: v0.15.0
https://github.com/kubernetes/minikube/issues/1067
When you map directories from the host directly into your container with volume mounts like these:
docker run -it --rm \
-v "$(PWD)/conf.d:/etc/nginx/conf.d":ro -v "$(PWD)/data:/data":ro \
-p 8085:80 nginx
The files are mounted directly in with the same uid's and file permissions you have on your host. Most likely your UID/GID on your host does not match those used inside the container. So if the files are not publicly readable on your host, they will not be readable inside the container. You can work around this with the following on your host:
chmod o+rx data && chmod o+r data/file.json
I run the following command at uni to my user account
chmod -R 700 *
Then, I run
chmod -R 755 public_html
My homepage remains to be "Forbidden" when I browse to it.
The permissions of my user account
4 drwx------ 5 Newbie staff 4096 2008-12-19 12:39 Desktop
4 drwx------ 10 Newbie staff 4096 2009-04-16 02:28 Documents
4 drwx------ 4 Newbie staff 4096 2008-11-28 20:48 irclogs
4 -rwx------ 1 Newbie staff 1686 2008-09-10 16:00 kieli
4 drwxr-xr-x 3 Newbie www 4096 2009-04-16 02:14 public_html
4 drwx------ 2 Newbie staff 4096 2008-09-01 08:43 Templates
4 drwx------ 4 Newbie staff 4096 2008-12-21 03:15 tmp
4 drwx------ 7 Newbie staff 4096 2008-09-03 21:39 Windows
4 drwx------ 4 Newbie staff 4096 2008-10-03 16:29 workspace
The permissions of files in public_html
4 -rwxr-xr-x 1 newbie staff 3414 2009-04-15 02:23 index.html
4 -rwxr-xr-x 1 newbie staff 2219 2008-09-16 10:46 index.html~
144 -rwxr-xr-x 1 newbie staff 140120 2009-04-14 22:16 jquery.js
4 -rwxr-xr-x 1 newbie staff 699 2009-04-15 01:05 template.css
Well, your second chmod doesn't seem to be working very well, since your public_html directory is mode 744, not 755.
You'll also need to make it so that your home directory can be "looked through" by the Web server; www user needs execute permission on the directory. chmod o+x . is probably your best bet.
Do you have an index file in the directory?
You would also need to give excute permission to the files in public_html. In the statement you are giving permissions chmod -R 755 public_html, still the permissions given is only 744. So give the execute permissions as well.
I found another bug.
My user folder had the permissions 700.
I changed it to 701.
I can now see my website.
It seems that 701 is required.