Skip to content

Commit 496d276

Browse files
committed
Add container labels
1 parent 45d5258 commit 496d276

2 files changed

Lines changed: 21 additions & 4 deletions

File tree

docker-compose.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@
1616
#
1717
# see: https://github.com/FIWARE/helm-charts/
1818
#
19-
version: "3.5"
19+
version: "3.8"
2020
services:
2121
# Orion is the context broker
2222
orion:
23+
labels:
24+
org.fiware: 'tutorial'
2325
image: fiware/orion:${ORION_VERSION}
2426
container_name: fiware-orion
2527
depends_on:
@@ -36,6 +38,8 @@ services:
3638
interval: 5s
3739
# Keyrock is an Identity Management Front-End
3840
keyrock:
41+
labels:
42+
org.fiware: 'tutorial'
3943
image: fiware/idm:${KEYROCK_VERSION}
4044
container_name: fiware-keyrock
4145
hostname: keyrock
@@ -70,6 +74,8 @@ services:
7074

7175
# Tutorial acts as a series of dummy IoT Sensors over HTTP
7276
tutorial:
77+
labels:
78+
org.fiware: 'tutorial'
7379
image: fiware/tutorials.context-provider
7480
hostname: iot-sensors
7581
container_name: fiware-tutorial
@@ -116,6 +122,8 @@ services:
116122

117123
# Databases
118124
mongo-db:
125+
labels:
126+
org.fiware: 'tutorial'
119127
image: mongo:${MONGO_DB_VERSION}
120128
hostname: mongo-db
121129
container_name: db-mongo
@@ -136,6 +144,8 @@ services:
136144

137145
mysql-db:
138146
restart: always
147+
labels:
148+
org.fiware: 'tutorial'
139149
image: mysql:${MYSQL_DB_VERSION}
140150
hostname: mysql-db
141151
container_name: db-mysql
@@ -157,6 +167,8 @@ services:
157167

158168
networks:
159169
default:
170+
labels:
171+
org.fiware: 'tutorial'
160172
ipam:
161173
config:
162174
- subnet: 172.18.1.0/24

services

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,20 @@ startContainers () {
5454
}
5555

5656
stoppingContainers () {
57-
CONTAINERS=$(docker ps -aq)
57+
CONTAINERS=$(docker ps --filter "label=org.fiware=tutorial" -aq)
5858
if [[ -n $CONTAINERS ]]; then
5959
echo "Stopping containers"
60-
docker rm -f $CONTAINERS
60+
docker rm -f $CONTAINERS || true
6161
fi
6262
VOLUMES=$(docker volume ls -qf dangling=true)
6363
if [[ -n $VOLUMES ]]; then
6464
echo "Removing old volumes"
65-
docker volume rm $VOLUMES
65+
docker volume rm $VOLUMES || true
66+
fi
67+
NETWORKS=$(docker network ls --filter "label=org.fiware=tutorial" -q)
68+
if [[ -n $NETWORKS ]]; then
69+
echo "Removing tutorial networks"
70+
docker network rm $NETWORKS || true
6671
fi
6772
}
6873

0 commit comments

Comments
 (0)