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


docker

D-Laravel on .env and docker-compsoe small classroom

This article introduces why the docker-compose ps official command cannot list all the services in use when we use D-Laravel's .env to load multiple yml files. But the ./console ps on D-Laravel can indeed display normally, so how can the official docker-compose command be used to have the same effect?

docker,phpenv

Ran out of Docker IPv4 address pool problem solving

Maybe in the old version of the docker environment, when using Docker compose to start the container, you will encounter the following error: Error response from daemon: could not find an available, non-overlapping IPv4 address pool among the defaults to assign to the network This is actually this It is a symptom of running out of default-address-pools. In some environments, docker-compose will use the private network of Class B by default. The private IP of segment 172 has a range, from 172.16.0.0 to 172.31.255.255. That is to say, when we start a docker-compose Project, it will eat a private section of Class B, which is very heroic.

linux,docker,wifi

Use docker to build a WPA2/EAP enterprise Radius authentication server, and the backend uses a mysql database

AP provides WPA2/EAP function, but it won't work? This article introduces how I can quickly build a Radius server through docker's ubuntu:21.04 image. Related applications such as WPA2/EAP of Wifi.