Skip to content

Commit 118607e

Browse files
committed
Add container labels
1 parent 31dc33c commit 118607e

2 files changed

Lines changed: 23 additions & 4 deletions

File tree

docker-compose.yml

Lines changed: 15 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:
@@ -37,6 +39,8 @@ services:
3739

3840
# IoT-Agent is configured for the UltraLight Protocol
3941
iot-agent:
42+
labels:
43+
org.fiware: 'tutorial'
4044
image: fiware/iotagent-ul:${ULTRALIGHT_VERSION}
4145
hostname: iot-agent
4246
container_name: fiware-iot-agent
@@ -68,6 +72,8 @@ services:
6872

6973
# Keyrock is an Identity Management Front-End
7074
keyrock:
75+
labels:
76+
org.fiware: 'tutorial'
7177
image: fiware/idm:${KEYROCK_VERSION}
7278
container_name: fiware-keyrock
7379
hostname: keyrock
@@ -99,6 +105,8 @@ services:
99105

100106
# Tutorial acts as a series of dummy IoT Sensors over HTTP
101107
tutorial:
108+
labels:
109+
org.fiware: 'tutorial'
102110
image: fiware/tutorials.context-provider
103111
hostname: iot-sensors
104112
container_name: fiware-tutorial
@@ -147,6 +155,8 @@ services:
147155

148156
# Databases
149157
mongo-db:
158+
labels:
159+
org.fiware: 'tutorial'
150160
image: mongo:${MONGO_DB_VERSION}
151161
hostname: mongo-db
152162
container_name: db-mongo
@@ -167,6 +177,8 @@ services:
167177

168178
mysql-db:
169179
restart: always
180+
labels:
181+
org.fiware: 'tutorial'
170182
image: mysql:${MYSQL_DB_VERSION}
171183
hostname: mysql-db
172184
container_name: db-mysql
@@ -188,6 +200,8 @@ services:
188200

189201
networks:
190202
default:
203+
labels:
204+
org.fiware: 'tutorial'
191205
ipam:
192206
config:
193207
- subnet: 172.18.1.0/24

services

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

132132
stoppingContainers () {
133-
CONTAINERS=$(docker ps -aq)
133+
CONTAINERS=$(docker ps --filter "label=org.fiware=tutorial" -aq)
134134
if [[ -n $CONTAINERS ]]; then
135135
echo "Stopping containers"
136-
docker rm -f $CONTAINERS
136+
docker rm -f $CONTAINERS || true
137137
fi
138138
VOLUMES=$(docker volume ls -qf dangling=true)
139139
if [[ -n $VOLUMES ]]; then
140140
echo "Removing old volumes"
141-
docker volume rm $VOLUMES
141+
docker volume rm $VOLUMES || true
142+
fi
143+
NETWORKS=$(docker network ls --filter "label=org.fiware=tutorial" -q)
144+
if [[ -n $NETWORKS ]]; then
145+
echo "Removing tutorial networks"
146+
docker network rm $NETWORKS || true
142147
fi
143148
}
144149

0 commit comments

Comments
 (0)