by Devin Yang
(This article was automatically translated.)

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

D-Laravel's console command lets us quickly understand what he executes. How is it executed if docker-compose is used?
Let's see.

The following is the actual implementation

1. In the picture, I executed the ls command of Linux to check whether there is a docker-compose.yml file. The docker-compose command is to use the recursive method to find the directory layer by layer.
docker-compose command, as long as you find the docker-compose.yml file, you can create an execution container according to the settings in the file.

2. Let's take a look. In the picture, I executed the ./console command. This bash helps us execute docker-compose very quickly. console command without parameters,
In the setting of D-Laravel, it is to enter the container of the php service.
So obviously, I entered the container after executing ./console
Readers, have you noticed that when the ./console command is executed, a line of official commands is printed at the bottom?
docker-compose -f /Users/devin/dlaravel/docker-compose.yml exec -u dlaravel php bash
This is to let us understand what ./console does. It just runs the docker-compose command. Obviously, -f indicates the use of the docker-compose.yml file.
And -u is what kind of identity to use in the container, which is one of the reasons why you can execute the console command of setting an alias anywhere.

3. That being the case, we are in the directory of dlaravel, and the default user of the new version of fpm image is also dlaravel, and the commands can of course be checked.
Looking at the picture, I entered the following command and can enter the container of the php service normally:
docker-compose exec php bash
(Note: php is the service name of the container, and bash is the command you want to execute in the container. You can change bash to top to see, and it will run the top command in the container.)

The result of execution is the same as the result of ./console, right?
So, you can also try more commands, such as the following:
./console ps

docker-compose ps
The results of these two instructions must be the same, because they both do the same thing (so what to do with the console, it will be much faster to auto-completion).

I am mixed, that’s it, if you use the .env file of dlaravel, you basically need to use the console command completely.
Of course, you can move some of the related services you want to docker-compose.yml, which is OK. After all, just use the console,
Wouldn’t it be great if console + .env could expand more services arbitrarily? :)

Finally, I hope you have a deeper understanding of D-Laravel and docker-compose after reading this article. :)


Tags: docker laravel

Devin Yang

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

No Comment

Post your comment

Login is required to leave comments