I’m new to Docker.
Until now, I was working with wamp and several projets.
So I decided to switch each project to Docker and I notice poor performance on all projects.
For sure, we can ask if projects are optimized but this is another topic as I compare the same projets on the same computer and there is a big difference between Docker and wamp execution.
So I think I don’t do things correctly in my Docker configuration or containers configuration.
How can I check this, do you have clues for me ?
I’m using Docker Desktop out of the box
Thanks a lots for your help
Please make sure you are not mounting folders from the windows host into the container, as it will slow down file access. Use named volumes (that will be stored inside WSL and therefor on a linux ext4 filesystem).
You can still access the files from windows using
\\WSL$\docker-desktop-data (works for Win10/Win11) or
\\wsl.localhost\docker-desktop-data (works on Win11).
Within the docker-desktop-data wsl-distribution you have to find the rest of the path, people reported different folders inside the distribution to be correct.
For instance on my Win11 installation, I can see the named volumes in
As this is my dev machine, I mounted the project to work on it with phpStorm
Here is my file structure:
| |_ vhosts
| | |_ vhosts.conf
| |_ Dockerfile
So, what is the good practice ?
For database first ? I need to have database to be persistent but no need to access it from windows host
For project files ? I need to see them in my IDE
Actually having project files into container folder is really usefull as my git is on top of that. So, I can commit the whole container structure including project files
What do you suggest me ?
Thanks a lot
As I don’t need to access database files from Windows, I used db-data volume instead of bind mount
I’m discovering volumes (shared and local) and I have now many questions
Instead of having for each projet the following containers:
Is it not a better idea to share the same network between my projects and have:
- only one mailDev for all
- only one phpMyAdmin for all
- one MySql per needed version
- All the databases requiring the same MySql version on the same MySql server
The remaining problem is to share project files (and git) with phpStorm
Thanks again for your help
You have multiple options, but using Docker Desktop may change things.
- You can keep your project files on the WSL’s filesystem and open the whole project from the IDE (details later).
- Install Docker in the WSL distribution directly without Docker desktop and you can use Docker as you would use it on any Linux OS.
- Use Docker Desktop in which case Docker will have its own distribution, but you can turn on WSL integration and zse the docker client from an other. IT would be a remote connection, but since WSL distributions can access files from an other distribution through the mounted folders in
/mnt/wsl, if you use that folder for your source path, I think it could work.
- Use Docker Desktop and create a new “Dev Environment”. It is a beta feature, but using it you can copy your project into a dev container and connect to the dev container from Visual Studio Code as a remove host. Docker Desktop will give you a button next to the dev container’s name to open the code from VSCode.
Different IDEs have different remote host support. JetBRains IDEs like PHPStorm (which I use as well) has a pretty bad remote host support compared to Visual Studio Code. in PHPStorm you can syncronize your sourcode using rsync (this is the better way) or use JetBrains Gateway to run it on the remote host but it would use a lot more resources than Visual Studio Code. So when I really need a remote host support, I prefer to use Visual Studio Code but usually I like JetBrains IDEs more.
It depends on what you want. On your machine during development, you can have multiple mysql servers, one for each project since they will probably not run all the time, but it is much easier to have everything in one place suring development and make sure that one single project would work and you can worry about compatibility with a central database later. If you discover an issue, you can test different configurations and create a readme file to describe the required parameters in different cases.
If you are running your project in production, you would not want to run multiple production database servers. In that case you can create an external “database” and attach your your database server’s container and the client containers (php containers or any container that needs ro use that database server) to this network so.
Using multiple PHPMyAdmin and mailDev could work in production too, but I would not use them in production at all, unless you are a hosting and you have a client who needs a PHPMyAdmin.Even if you have PHPmyAdmin in production, if you are the only one who needs it or everyone has SSH access to the host, you can run PHPMyAdmin on a local port and use SSH tunnel to access it when it is necessary. I use MySQLWorkbench this way without PHPMyAdmin
Thanks for all
I’ve found he following workaroud:
- Install Ubuntu into WSL
- Install Docker into Ubuntu
- Create un root folder in Ubuntu for all containers and project
- Run container from this folder
- Open project from PhpStorm with network path \wsl\Ubuntu\pathToContainer
The default webpage from Symfony (without database call) had 3sec generating time. Now, It’s about 20ms !!!
Thanks for your help