bashdockergit-bashshopware6chown

Shopware 6: Docker exec chown fails in Git Bash script with "No such file or directory"


I have a Git Bash script that runs some Docker commands to set up my Shopware container. One of the commands uses docker exec to run sudo chown on a path inside the container:

docker exec -it $SHOPWARE_CONTAINER_ID sudo chown www-data /var/www/html/custom/plugins/shopware-ai-demodata/src/Service/Generator/

This works fine when the command is run inside the container using the docker desktop. However, if I run the script, it gives an error in Git Bash (Windows OS):

chown: cannot access 'C:/Program Files/Git/var/www/html/custom/plugins/shopware-ai-demodata/src/Service/Generator/': No such file or directory

It seems like it is trying to run chown directly on my Windows host instead of inside the Docker container since the path clearly doesn't exist natively on Windows. How can I make this command work inside the shopware container via script?


Solution

  • That's Git bash trying to expand things like /bin/sh to an executable in its own path. To disable it, you double the first slash:

    docker exec -it $SHOPWARE_CONTAINER_ID sudo chown www-data //var/www/html/custom/plugins/shopware-ai-demodata/src/Service/Generator/