Reputation: 3940
I develop a PHP Symfony application on Docker on a Windows machine. For doing Doctrine migrations, I want to set up an easy way to run those commands inside the PHP container. On work, we have a solution for this but it's on Linux. The solution is this shell script which is named "console":
#!/usr/bin/env bash
docker exec it $(docker-compose ps -q php | head -1) bin/console "$@"
Now you can do console doctrine:migrations:diff
and what happens is: a shell to the PHP container is opened and the arguments "doctrine:migrations:diff" are inserted after bin/console resulting effectively in a call bin/console doctrine:migrations:status
inside the PHP container.
What I'd like to achieve now is the described above on a Windows machine. I tried to write console.bat like this which just halts inside the PHP container:
docker exec -ti freeenergy_php_1 /bin/bash
doctrine:migrations:status
I also tried this:
docker exec -ti freeenergy_php_1 /bin/bash < doctrine:migrations:status
This fails with:
docker exec -ti freeenergy_php_1 /bin/bash 0 < doctrine:migrations:status The filename, directory name, or volume label syntax is incorrect.
Upvotes: 1
Views: 209
Reputation: 3940
I found this -c parameter in the documentation of docker exec which works. The console.bat file now looks like this:
docker exec -ti freeenergy_php_1 /bin/bash -c "bin/console %*"
Upvotes: 1