docker compose命令(Docker compose command)

docker-compose -f docker-compose-nacos.yml -p nacos up -d

-f:指定使用的compose模板文件,默认为当前目录下的docker-compose.yaml文件,可以多次指定。

-p:指定项目的名称,默认将使用所在目录名称作为项目名。

up:启动服务。该命令十分强大,它将尝试自动完成包括构建镜像,(重新)创建服务,启动服务,并关联服务相关容器的一系列操作。

链接的服务都将会被自动启动,除非已经处于运行状态。

可以说,大部分时候都可以直接通过该命令来启动一个项目。

默认情况,docker-compose up 启动的容器都在前台,控制台将会同时打印所有容器的输出信息,可以很方便进行调试。

当通过 Ctrl-C 停止命令时,所有容器将会停止。

如果使用 docker-compose up -d,将会在后台启动并运行所有的容器。一般推荐生产环境下使用该选项。

-d:在后台运行服务容器;

————————
docker-compose -f docker-compose-nacos.yml -p nacos up -d

-f: Specify the composition template file to be used. The default is docker composition.exe in the current directory Yaml file, which can be specified multiple times.

-p: Specify the name of the project. By default, the name of the directory will be used as the project name.

Up: start the service. This command is very powerful. It will attempt to automatically complete a series of operations, including building an image, (RE) creating a service, starting a service, and associating a service related container.

All linked services will be started automatically unless they are already running.

It can be said that most of the time, you can start a project directly through this command.

By default, all containers started by docker compose up are in the foreground, and the console will print the output information of all containers at the same time, which is convenient for debugging.

When you stop the command through ctrl-c, all containers will stop.

If docker compose up – D is used, all containers will be started and run in the background. This option is generally recommended for production environments.

-d: Running the service container in the background;