Lab #20: Kill Command

Command instructions

Kill

Verify if the kill command kills all the container started by the docker-compose and verify if there is any running container after killing it.

Pre-requisite:

Tested Infrastructure

Platform Number of Instance Reading Time
Play with Docker 1 5 min

Pre-requisite

Initial setup

$ mkdir app
$ cd app

Create a docker-compose.yml file

version: '3.1'
services:
   webserver:
     image: nginx:alpine
     expose:
       - "80"
   loadbalancer:
     image: nginx:alpine
     volumes:
       - ./nginx.conf:/etc/nginx/nginx.conf:ro
     depends_on:
       - webserver
     ports:
       - "80:4000"

Create the compose containers

$ docker-compose up -d --scale webserver=3

View the containers

$ docker-compose ps

Kill all the containers

$ docker-compose kill

Check if there are any running containers

$ docker-compose ps

Next ยป Lab #21: Rm Command