TransWikia.com

sed: cannot rename ./sed6x9apB: Operation not permitted using docker-compose with WordPress image

Super User Asked by AndrewD on December 3, 2020

WordPress container fails to start when using docker-compose, where there are existing WordPress files, aborting with the following error:

sed: cannot rename ./sedtpghTB: Operation not permitted

Error only occurs when WordPress files are hosted on a VirtualBox (vboxsf) shared folder. Sharing the folder over SMB/CIFS avoids the error.

Setup:

  • Host: Win 10 (64b)
  • Guest: 3.16.0-4-amd64 (debian_version 8.6) Guest/Vbox version: 5.1.12 r112440 (Qt5.6.2)
  • WordPress files are shared out using a VirtualBox shared folder mounted at /media/vmhost

Here is the output of docker-compose config:

        networks: {}
        services:
          db:
            environment:
              MYSQL_DATABASE: my_db_name
              MYSQL_PASSWORD: 'MY_ROOT_PASSWORD'
              MYSQL_ROOT_PASSWORD: 'MY_ROOT_PASSWORD'
              MYSQL_USER: root
            image: mysql:5.7
            ports:
            - 3306:3306
            restart: never
            volumes:
            - db_data:/var/lib/mysql:rw
          wordpress:
            depends_on:
            - db
            environment:
              WORDPRESS_DB_HOST: db:3306
              WORDPRESS_DB_NAME: my_db_name
              WORDPRESS_DB_PASSWORD: 'MY_PASSWORD'
              WORDPRESS_DB_USER: root
            image: wordpress:latest
            ports:
            - 80:80
            restart: never
            volumes:
            - /media/vmhost/www/test:/var/www:rw
            - /media/vmhost/www/test/public_html:/var/www/html:rw
        version: '2.0'
        volumes:
          db_data: {}
          wp_data: {}

When I attempt a sed on the vboxsf share, I get a similar error, but only when the source file is readonly.

echo 'hello' > hello.txt
chmod a-w hello.txt
sed -i  's/hello/goodbye/' hello.txt

error:

sed: cannot rename ./sed6x9apB: Operation not permitted

output of mount | grep www

    www on /media/vmhost/www type vboxsf (rw,nodev,relatime)

When I use a CIFS share , mounted at /media/vmhost/www2 , everything works fine.

//my_laptop/www on /media/vmhost/www2 type cifs (rw,relatime,vers=1.0,sec=ntlm,cache=strict,username=vboxsf,uid=0,noforceuid,gid=0,noforcegid,addr=192.168.1.5,file_mode=0777,dir_mode=0777,nounix,serverino,noperm,rsize=61440,wsize=65536,actimeo=1)

One Answer

This appears to be a bug with VirtualBox, see Ticket #4890 .

Per frank's reply:

fixed for Linux hosts but not for Windows hosts. In contrast to Linux where a file can be removed if the directory is writable but the file itself is read-only, a read-only file cannot be removed on Windows

This impacts sed since sed makes a copy of the source file ( in this case wp-config-sample.php ) to a temporary file, and then attempts to make the replacements which windows won't support since the copy is also readonly.

For some reason, a proper share using CIFs is not impacted.

Workaround 1: Make the source file writeable and restart the container.

chmod a+w wp-config-sample.php docker-compose up

Workaround 2: Use a CIFS share.

  1. On your Windows machine, share out the directory containing your WordPress files using the Windows Advanced sharing properties of the directory.
  2. On your VirtualBox VM, add the following to /etc/fstab

    //my_laptop/www  /media/vmhost/www  cifs  username=WINDOWS_USER,password=WINDOWS_USER_PASSWORD,file_mode=0777,dir_mode=0777,iocharset=utf8,noperm,sec=ntlm  0  0
    
  3. mount

    mount -a

Answered by AndrewD on December 3, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP