dockware
Search…
Bind-Mounting
Since the Docker engine is getting better, the performance losses especially on MACs are not as big as they used to be when using bind-mounting in projects such as Symfony or Shopware.
Some of you know, that we like the SFTP way, as it's the best controllable and platform independent way to handle the project and file permissions.
But it's not the only approach of dockware and us! It's a fallback that always works!
Bind-Mounting is a plain Docker feature and has nothing to do with dockware itself. Thus, all related things, including issues such as file permission problems do not have to do anything with dockware. Please keep that in mind when searching for answers to problems.
WINDOWS Users: Please see also this page for now, until we had time to integrate it in this page. Thank you for your understanding: https://github.com/dockware/docs/issues/3

New Project

If you are not a plugin developer, but have a full shop instead, please make sure to read our guide about creating a new project.
This is required, because starting a new project immediately with bind-mount would lead to an empty folder, and thus no Shopware.
So with bind-mounting, you first need your source code on your host machine.

MAC

If you are working on a MAC, then bind-mounting works really good. You only need to exclude a few folders from your container, and it works blazing fast.
Below are 2 use cases with samples of folders that should usually be excluded. Feel free to improve these for your custom projects.
We recommend excluding every large folder that you don't need locally (logs, caches, node_modules, ...)
The excluded folders will be based on anonymous volumes. It's like a a persistent volume...only without a name and known destination.
This means, that if you have a node_modules folder as an anonymous volume, it only exists in Docker, but not on your host, which is the solution to speed up things. But this also means that Docker is the owner of those folders, which brings a small disadvantage.
If you want to delete those folders in your scripts (like the vendor), then you get an error "Device is busy". The solution is to simply delete the contents of that folder, instead of the folder itself.
1
rm -rf ...../vendor/*
Copied!
To continue using all your scripts and commands as usual, you have to set permissions on these folders after starting your container. You can set these individually per folder, or just use this command and all is good:
1
docker exec -it shop bash -c 'sudo chown www-data:www-data /var/www/html -R"
Copied!
That's it! You now have a bind-mounted Shopware on a MAC with a good performance.

Plugin Developer

docker-compose.yml
1
shop:
2
image: dockware/dev:6.4.9.0
3
container_name: my_shop
4
volumes:
5
- "./src/custom/plugins/MyPlugin:/var/www/html/custom/plugins/MyPlugin"
6
# exclude by using anonymous volumes
7
- "/var/www/html/custom/plugins/MyPlugin/.git/"
8
- "/var/www/html/custom/plugins/MyPlugin/vendor/"
9
- "/var/www/html/custom/plugins/MyPlugin/src/Resources/app/administration/node_modules/"
10
- "/var/www/html/custom/plugins/MyPlugin/src/Resources/app/storefront/node_modules/"
11
- "/var/www/html/custom/plugins/MyPlugin/tests/Cypress/"
12
...rest of docker-compose...
Copied!

Shop Developer

docker-compose.yml
1
shop:
2
image: dockware/essentials:latest
3
container_name: my_shop
4
volumes:
5
- "./src:/var/www/html/"
6
# ...excluding shopware default directories
7
- "/var/www/html/.git/"
8
- "/var/www/html/public/build"
9
- "/var/www/html/var/cache"
10
- "/var/www/html/vendor"
11
# ...additional project specific excludes...
12
- "/var/www/html/custom/plugins/MyPlugin/src/Resources/app/administration/node_modules/"
13
- "/var/www/html/custom/plugins/MyPlugin/src/Resources/app/storefront/node_modules/"
14
- "/var/www/html/custom/plugins/MyPlugin/tests/Cypress/"
15
...rest of docker-compose...
Copied!

Linux

Bind-Mounting on Linux works great! You can simply mount the whole DocRoot without any performance loss.
However, if you are a plugin developer, we would still recommend only mounting your custom plugin. This allows you to easily switch the Shopware version around your plugin.
Here are 2 samples for plugin developers and developers who are in charge of full shops.

Plugin Developer

1
shop:
2
image: dockware/dev:6.4.9.0
3
container_name: my_shop
4
volumes:
5
- "./src/custom/plugins/MyPlugin:/var/www/html/custom/plugins/MyPlugin"
6
...rest of docker-compose...
Copied!

Shop Developer

docker-compose.yml
1
shop:
2
image: dockware/essentials:latest
3
container_name: my_shop
4
volumes:
5
- "./src:/var/www/html/"
6
...rest of docker-compose...
Copied!
Linux has some great options for permissions. If you face any troubles while developing, you can do the following:
Make sure that both your host (and users) as well as the Docker container work with the same permission group. We recommend ID 33, which is also known as "www-data".
Then simply change the permissions of your source folder
1
# change basic permissions (you might need sudo)
2
chgrp -R 33 ./src
3
# write permissions for cache/log folder required
4
chmod a+w ./src/var/*
Copied!
Another approach would be to run this command in your container after starting it. It should fix all permissions if something is broken
1
sudo chown www-data:www-data /var/www/html -R
Copied!
There would also be an easy make command to fix permissions in /var/www.
Please keep in mind, this guide is meant for development. When it comes to a hosted installation on a Linux server, we have more instructions about strategies and permissions on this page.

Important Notices

Keep in mind, when you upload with SFTP while having an active bind-mount, that will remove thecontent of the files! Do not mix both ways!