docker compose命令(Docker compose command)

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






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

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

如果使用 docker-compose up -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;