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


wordpress, d-laravel, docker, docker-compose

How to install Wordpress with D-Laravel

An 8-minute teaching video, introducing the installation of Wordpress on D-Laravel. D-Laravel is a docker-compose Laravel framework development environment, but it does not mean that it cannot be used to install other things. This video introduces the use of D-Laravel to install non-Laravel PHP projects, You can learn the usage of related instructions on D-Laravel: ./create --host usage, docker-compose up -d and ./console mysql usage, The database connection setting method after D-Laravel v1.0.0.

linux,docker

How to execute X client and X Window in Container (docker gui)

Today I will talk to you about X, not iPhone X, nor X-Men, but X Window System, He is the main graphical interface display component of the current Linux system. Since it is very easy to expand and modularize, it has been used since it was established in 1986. The X Window system adopts the Client/Server architecture, which splits the application program and the display into two. The application program of X Windows is usually called X Client, and the display is the well-known X Server. The X client communicates with the X server through the X protocol (X protocol), which is an asynchronous network communication protocol.

docker

Docker antivirus strategy

I just watched Story of Yanxi Palace recently, so I wanted to introduce a MacOS anti-drug strategy. This article teaches you how to use Docker to clean MacOS. Briefly introduce how we use anti-virus software to scan viruses through docker. It is assumed that my current directory is in my home directory, so ${PWD} is the current directory and will be mounted to the scan folder in the container. Therefore, when you use clamscan -r /scan/, you can scan all the files. Adding the -r parameter will use the recursive method to enter the subdirectory layer by layer to scan.