Docker-compose.yml file:

version: "3" services: webserver: image: nginx ports: - "80:80" volumes: - .:/usr/share/nginx/html 

I create service: docker-compose -p my up --no-start

I look at the list of containers: docker container ps -a

 CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 99dabcf2b2cf nginx "nginx -g 'daemon of…" 4 seconds ago Created my_webserver_1_5f7310de9b9a 

Trying to run: docker-compose start

 Starting webserver ... done ERROR: No containers to start 

But it works if you do not specify the name ( -p my )

I flipped through the commands in .bash_history, then suddenly I enter something wrong, so not - the same commands. Yesterday it worked, today did not update anything.

Version: docker-compose version 1.23.1, build b02f1306

  • and if docker-compose -p my start ? - kami

1 answer 1

We look at the documentation:

COMPOSE_PROJECT_NAME Sets the project name. This is the case for the container on start up. For example, if your project name is myapp_db_1 and myapp_web_1 respectively. Setting this is optional. If you don’t set this, the COMPOSE_PROJECT_NAME defaults to the basename of the project directory. See also the -p command-line option.

We draw conclusions: created a container with the prefix "my" (the -p flag), then you probably need to launch it as well (either create and run without -p with the default value).

  • Yes, I understand, it turned out, you need to specify the name of the container, if this name was specified when creating the container. Thank you very much! - Anton