Labels can be attached to containers when they are launched via
docker run. A container can have multiple labels attached to them at any one time.
Notice in this example, because we're using the labels are for use with the CLI, and not an automated tool, we're not using the DNS notation format.
To add a single label you use the l
docker run -l user=12345 -d redis
If you're adding multiple labels, then these can come from an external file. The file needs to have a label on each line, and then these will be attached to the running container.
This line creates two labels in the file, one for the user and the second assigning a role.
echo 'user=123461' >> labels && echo 'role=cache' >> labels
The --label-file=<filename> option will create a label for each line in the file.
docker run --label-file=labels -d redis