dockware
  • dockware doc's
  • News
  • Setup
    • Docker Setup
    • What Image should you use?
    • Performance Tweaks
  • Use Dockware
    • First Run
    • Update Dockware
    • Advanced Run
    • Default Credentials
    • Symfony or Shopware 5
    • Changelog
  • Features
    • Intro
    • Environment Variables
    • Adminer
    • Mailcatcher
    • Switch PHP Version
    • Switch Node Version
    • Tideways Profiling
    • Pimp my Log
    • Filebeat
    • SSH Users
    • MySQL Users
    • Shopware Currency
  • Development
    • Intro
    • Start Developing
    • Switch Branches
    • Debugging
    • Watchers
    • App Development
    • Update Shopware
    • Dockware Essentials
    • Custom Domains
    • Custom Images
    • Code Coverage
    • CLI Build Shopware 6 Plugin
    • Multi-Environment Setups
  • Contribute
    • Intro
    • Setup Github Version
    • Create Feature
    • Code Styles
    • Testing
    • Create Pull Requests
  • CI/CD
    • Github
    • Gitlab
    • Bitbucket
    • Buddy
  • Tips & Tricks
    • Create a new Project
    • Bind-Mounting
    • Persisting Data
    • Housekeeping
    • Online Servers
    • Performance on Mac
    • Security
  • FAQ
    • Sequel Pro
    • Dockware and other images
    • Scripts (PSH?)
    • Redis
    • Error Port not available
    • MySQL failed
    • Elasticsearch
    • Windows Problems
    • Chrome Problems
    • Import MySQL Dump
    • Shopware 5 Support
    • Use Https/SSL
    • Container hangs in Pipeline
    • Disable the admin worker
  • Additional Links
    • Imprint
    • Founders
    • Dockware website
    • Dockware in Shopware Slack
Powered by GitBook
On this page
  • New Project
  • MAC
  • Plugin Developer
  • Shop Developer
  • Linux
  • Plugin Developer
  • Shop Developer
  • Important Notices

Was this helpful?

  1. Tips & Tricks

Bind-Mounting

PreviousCreate a new ProjectNextPersisting Data

Last updated 2 years ago

Was this helpful?

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:

New Project

If you are not a plugin developer, but have a full shop instead, please make sure to read our guide about .

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.

rm -rf ...../vendor/*

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:

docker exec -it shop bash -c 'sudo chown www-data:www-data /var/www/html -R'

That's it! You now have a bind-mounted Shopware on a MAC with a good performance.

Plugin Developer

docker-compose.yml
shop:
  image: dockware/dev:6.4.9.0
  container_name: my_shop
  volumes:
    - "./src/custom/plugins/MyPlugin:/var/www/html/custom/plugins/MyPlugin"
    # exclude by using anonymous volumes
    - "/var/www/html/custom/plugins/MyPlugin/.git/"
    - "/var/www/html/custom/plugins/MyPlugin/vendor/"
    - "/var/www/html/custom/plugins/MyPlugin/src/Resources/app/administration/node_modules/"
    - "/var/www/html/custom/plugins/MyPlugin/src/Resources/app/storefront/node_modules/"
    - "/var/www/html/custom/plugins/MyPlugin/tests/Cypress/"
   ...rest of docker-compose...

Shop Developer

docker-compose.yml
shop:
  image: dockware/essentials:latest
  container_name: my_shop
  volumes:
    - "./src:/var/www/html/"
    # ...excluding shopware default directories
    - "/var/www/html/.git/"
    - "/var/www/html/public/build"
    - "/var/www/html/var/cache"
    - "/var/www/html/vendor"
    # ...additional project specific excludes...
    - "/var/www/html/custom/plugins/MyPlugin/src/Resources/app/administration/node_modules/"
    - "/var/www/html/custom/plugins/MyPlugin/src/Resources/app/storefront/node_modules/"
    - "/var/www/html/custom/plugins/MyPlugin/tests/Cypress/"
   ...rest of docker-compose...

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

shop:
  image: dockware/dev:6.4.9.0
  container_name: my_shop
  volumes:
    - "./src/custom/plugins/MyPlugin:/var/www/html/custom/plugins/MyPlugin"
   ...rest of docker-compose...

Shop Developer

docker-compose.yml
shop:
  image: dockware/essentials:latest
  container_name: my_shop
  volumes:
    - "./src:/var/www/html/"
   ...rest of docker-compose...

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

# change basic permissions (you might need sudo)
chgrp -R 33 ./src
# write permissions for cache/log folder required
chmod a+w ./src/var/*

Another approach would be to run this command in your container after starting it. It should fix all permissions if something is broken

sudo chown www-data:www-data /var/www/html -R

There would also be an easy make command to fix permissions in /var/www.

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!

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

https://github.com/dockware/docs/issues/3
creating a new project
this page.