Unable to upgrade docker image. rsync: [receiver] rename "/var/www/html/.htaccess.l1fU92" -> ".htaccess": Device or resource busy (16)

Hi everyone,

I have been running the docker image of Nextcloud for years (not AiO) and just tried to upgrade it from 26 to 27. I performed the upgrade as usual, by taking down the container, pulling the new version, and putting it up again (has worked flawlessly previously).
But this time, I get the following error message for my app container:

“rsync: [receiver] rename “/var/www/html/.htaccess.l1fU92” → “.htaccess”: Device or resource busy (16)”"

Note that I upgraded docker just previously and had to switch to “overlay2” for the storage-driver, in case it’s relevant.

Any idea of what to do?
Thanks for the help!

Can you post your Docker compose file? Are you relying on Storage Drivers/the container’s writable layer rather than named volumes for your persistent storage? overlay2 has problems with rename() calls…

Thanks for answering. I am relying on both named volumes and “linked storage” (forgot how it’s called exactly) and the .htaccess is in fact not a named volume… Should put it in a named volume?

Warning: my compose file is probably not optimized and ugly, I scrambled it together a while ago from online sources without really understanding and never took the time to update it…

version: '3.5'                                                                                                                                                               
                                                                                                                                                                             
services:                                                                                                                                                                    
  app:                                                                                                                                                                       
    image: nextcloud:27                                                                                                                                                      
    restart: unless-stopped                                                                                                                                                  
    volumes:                                                                                                                                                                 
      - ./config:/var/www/html/config                                                                                                                                        
      - nextcloud_data:/var/www/html                                                                                                                                         
      - /home/docker/nextcloud/.htaccess:/var/www/html/.htaccess                                                                                                             
    environment:                                                                                                                                                             
      POSTGRES_HOST: 'nextcloud_db'                                                                                                                                          
      POSTGRES_DB: 'nextcloud'                                                                                                                                               
      POSTGRES_USER: 'user'                                                                                                                                              
      POSTGRES_PASSWORD: 'password'                                                                                                                                   
      NEXTCLOUD_HOSTNAME: my-host.abc                                                                                                                           
      OVERWRITEPROTOCOL: https                                                                                                                                               
    labels:                                                                                                                                                                  
      - "traefik.enable=true"                                                                                                                                                
      - "traefik.docker.network=traefik-proxy"                                                                                                                               
      - "traefik.port=80"                                                                                                                                                    
      # Entrypoint and TLS                                                                                                                                                   
      - "traefik.http.routers.nextcloud.entrypoints=https"                                                                                                                   
      - "traefik.http.routers.nextcloud.rule=Host(`my-host.abc`)" # Put in your hostname here, e.g. subdomain.domain.tld                                         
      - "traefik.http.routers.nextcloud.tls.certresolver=namecheap"                                                                                                          
      # Middlewares:                                                                                                                                                         
      - "traefik.http.routers.nextcloud.middlewares=nextcloud@docker"                                                                                                        
      # Middleware cloud adds additional headers:                                                                                                                            
      - "traefik.http.middlewares.nextcloud.headers.customFrameOptionsValue=SAMEORIGIN"                                                                                      
      - "traefik.http.middlewares.nextcloud.headers.framedeny=true"                                                                                                          
      - "traefik.http.middlewares.nextcloud.headers.sslredirect=true"                                                                                                        
      - "traefik.http.middlewares.nextcloud.headers.stsIncludeSubdomains=true"                                                                                               
      - "traefik.http.middlewares.nextcloud.headers.stsPreload=true"                                                                                                         
    depends_on:                                                                                                                                                              
      - nextcloud_db                                                                                                                                                         
                                                                                                                                                                             
    networks:                                                                                                                                                                
      - traefik-proxy                                                                                                                                                        
      - backend                                                                                                                                                              
    container_name: nextcloud-app

  nextcloud_db:                                                                                                                                                              
    image: postgres:13                                                                                                                                                       
    restart: unless-stopped                                                                                                                                                  
    volumes:                                                                                                                                                                 
      - nextcloud_db_postgres:/var/lib/postgresql/data/pgdata                                                                                                                
    environment:                                                                                                                                                             
      POSTGRES_USER: user                                                                                                                                                
      POSTGRES_PASSWORD: password                                                                                                                                     
      PGDATA: /var/lib/postgresql/data/pgdata                                                                                                                                
    networks:                                                                                                                                                                
      - backend                                                                                                                                                              
    container_name: nextcloud-db                                                                                                                                             
                                                                                                                                                                             
                                                                                                                                                                             
volumes:                                                                                                                                                                     
  nextcloud_data:                                                                                                                                                            
    external: true                                                                                                                                                           
  nextcloud_db_postgres:                                                                                                                                                     
    external: true                                                                                                                                                           
                                                                                                                                                                             
networks:                                                                                                                                                                    
  traefik-proxy:                                                                                                                                                             
    external:                                                                                                                                                                
      name: traefik-proxy                                                                                                                                                    
  backend:

Ok, I found a workaround

  1. comment the line with the link to the .htaccess in the docker-compose file,
  2. start the container once and wait until init is completed,
  3. stop the container and then uncomment the line
  4. start the container again.

The update to 27 has worked… still not sure how to deal with this normally and hope the problem will be solved when it comes to migrating to the next version!