Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker-compose stop not working after docker-compose -p <name> up

I am using docker-compose version 2. I am starting containers with docker-compose -p some_name up -d and trying to kill them with docker-compose stop. The commands exits with 0 code but the containers are still up and running.

Is this the expected behaviour for version? If yes, any idea how can I work around it?

my docker-compose.yml file looks like this

version: '2'
services:

  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:5.3.0
    ports:
      - "9200:9200"
    environment:
      ES_JAVA_OPTS: "-Xmx512m -Xms512m"
      xpack.security.enabled: "false"
      xpack.monitoring.enabled: "false"
      xpack.graph.enabled: "false"
      xpack.watcher.enabled: "false"
    ulimits:
      memlock:
        soft: -1
        hard: -1
      nofile:
        soft: 262144
        hard: 262144

  kafka-server:
    image: spotify/kafka
    environment:
      - TOPICS=my-topic
    ports:
     - "9092:9092"

  test:
    build: .
    depends_on:
      - elasticsearch
      - kafka-server

update

I found that the problem is caused by using the -p parameter and giving explicit prefix to the container. Still looking for the best way to solve it.

like image 896
LetsPlayYahtzee Avatar asked Apr 20 '17 11:04

LetsPlayYahtzee


People also ask

How do I stop after docker compose up?

To stop a docker application that is running in the foreground, you just have to press Ctrl-C as show above. But, to stop a docker application that is running in the background, use the docker-compose stop as shown below.

How do I stop running after docker?

To stop one or more running Docker containers, you can use the docker stop command. The syntax is simple: $ docker stop [OPTIONS] CONTAINER [CONTAINER...] You can specify one or more containers to stop.

How do I stop all docker compose services?

Kill All Containers Using Docker Compose If you do, killing multiple containers takes one command: docker-compose down. You could also run docker-compose without detached mode. If so, you'll just use ^C to kill all containers. And there you have it—all containers killed!

Does docker compose down Remove named volumes?

Networks and volumes defined as external are never removed. Anonymous volumes are not removed by default.


1 Answers

docker-compose -p [project_name] stop worked in my case. I had the same problem.

like image 179
Stefan Hueg Avatar answered Sep 20 '22 05:09

Stefan Hueg