It's very simple, just add an "alias":
alias laravel='docker run --rm -v ${PWD}:/ var/www/html -v ~/.dlaravel/cache:/home/dlaravel/.composer/cache -ti deviny/fpm:8.1.10 /home/dlaravel/.composer/vendor/bin/laravel'
In this command, the current folder of our host (host) will be mounted, and we have seen -v ${PWD}.
The container side (to the right of the colon) is: /var/www/html, because it is the default path for the deviny/fpm image to build the container.
-ti followed by the image we want to use, here I use deviny/fpm:8.1.10 version.
--rm means that the created container can be removed after execution.
That is to say, we have executed the laravel installation command in the container through docker, because we have mounted the directory on the host side.
Therefore, the directory generated in the container can be kept on the host side.
Paste the above alias to the terminal to test the function of Laravel installer directly.
If you want to take effect permanently, you can add it to the startup file of your own shell.
We can use $0 to see what shell we are using.
echo $0
Add the alias settings to the file.
For example: add /bin/zsh to
~/.zshrc
or bash
~/.bash_profile
Remember to execute source once to update.
For example, I am zsh
source ~/.zsh
No Comment
Post your comment