by Devin Yang
(This article was automatically translated.)

Published - 4 years ago ( Updated - 1 year ago )

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

Tags: docker php cli

Devin Yang

Feel free to ask me, if you don't get it.:)

No Comment

Post your comment

Login is required to leave comments

Similar Stories


php,docker,dlaravel

A brief introduction to the phpenv container environment I built

I don't have time to shoot an introduction video, so I'll just grab some pictures and introduce the container environment deviny/phpenv I use. https://github.com/DevinY/phpenvphpenv can be regarded as an evolutionary version of my previous D-Laravel open source project, conceptually extending the use of many Dlaravel operation methods. The update of the container tends to be controlled by the user to build his own image, so I am not very good at changing the version number. In fact, the php version number of D-Laravel seems to have not been changed for a long time:p

docker

About Docker's Logging Driver

Docker has a lot of built-in log mechanisms to help us obtain service information executed in the container. These mechanisms (mechanisms) we usually call logging drivers.

bash,cli

some commands to check cpu, ram and disk info in linux

Introduce those commands that can be used to check hardware information on the Linux host