Docker: Difference between revisions
Jump to navigation
Jump to search
Line 199: | Line 199: | ||
Depuis une autre machine: |
Depuis une autre machine: |
||
<pre> |
<pre> |
||
mosquitto_pub -h test.mosquitto.org -t fr/imag/air/iot -m " |
mosquitto_pub -h test.mosquitto.org -t fr/imag/air/iot -m "sensor deveui=1234567 temp=20.10;hum=56.0;pres=1013.25;wind=5.0;rainlast10min=5;rainlasthour=10" |
||
</pre> |
</pre> |
||
Vérifier la récupération du message dans l'onglet Debug de Node-RED. |
|||
=Arrêt d'une composition= |
=Arrêt d'une composition= |
Revision as of 10:04, 16 March 2016
Voir
Installation de Docker et Docker Compose
Sur MacOS
TODO
Sur Debian/Ubuntu
sudo apt-get update sudo apt-get install docker.io docker --help sudo apt-get install docker-compose sudo usermod -aG docker ${USER} sudo service docker status sudo service docker stop sudo service docker status sudo service docker start
Getting started
## . ## ## ## == ## ## ## ## ## === /"""""""""""""""""\___/ === ~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ / ===- ~~~ \______ o __/ \ \ __/ \____\_______/ > docker Usage: docker [OPTIONS] COMMAND [arg...] docker [ --help | -v | --version ] A self-sufficient runtime for containers. Options: --config=~/.docker Location of client config files -D, --debug Enable debug mode -H, --host=[] Daemon socket(s) to connect to -h, --help Print usage -l, --log-level=info Set the logging level --tls Use TLS; implied by --tlsverify --tlscacert=~/.docker/ca.pem Trust certs signed only by this CA --tlscert=~/.docker/cert.pem Path to TLS certificate file --tlskey=~/.docker/key.pem Path to TLS key file --tlsverify Use TLS and verify the remote -v, --version Print version information and quit Commands: attach Attach to a running container build Build an image from a Dockerfile commit Create a new image from a container's changes cp Copy files/folders between a container and the local filesystem create Create a new container diff Inspect changes on a container's filesystem events Get real time events from the server exec Run a command in a running container export Export a container's filesystem as a tar archive history Show the history of an image images List images import Import the contents from a tarball to create a filesystem image info Display system-wide information inspect Return low-level information on a container or image kill Kill a running container load Load an image from a tar archive or STDIN login Register or log in to a Docker registry logout Log out from a Docker registry logs Fetch the logs of a container network Manage Docker networks pause Pause all processes within a container port List port mappings or a specific mapping for the CONTAINER ps List containers pull Pull an image or a repository from a registry push Push an image or a repository to a registry rename Rename a container restart Restart a container rm Remove one or more containers rmi Remove one or more images run Run a command in a new container save Save an image(s) to a tar archive search Search the Docker Hub for images start Start one or more stopped containers stats Display a live stream of container(s) resource usage statistics stop Stop a running container tag Tag an image into a repository top Display the running processes of a container unpause Unpause all processes within a container update Update resources of one or more containers version Show the Docker version information volume Manage Docker volumes wait Block until a container stops, then print its exit code Run 'docker COMMAND --help' for more information on a command.
docker-compose --help Define and run multi-container applications with Docker. Usage: docker-compose [options] [COMMAND] [ARGS...] docker-compose -h|--help Options: -f, --file FILE Specify an alternate compose file (default: docker-compose.yml) -p, --project-name NAME Specify an alternate project name (default: directory name) --verbose Show more output -v, --version Print version and exit Commands: build Build or rebuild services help Get help on a command kill Kill containers logs View output from containers port Print the public port for a port binding ps List containers pull Pulls service images restart Restart services rm Remove stopped containers run Run a one-off command scale Set number of containers for a service start Start services stop Stop services up Create and start containers migrate-to-labels Recreate containers to add labels
Déploiement d'un conteneur
docker pull mesoscloud/zookeeper
docker pull ansi/mosquitto
Déploiment d'une composition
Créer le descripteur suivant pour cet stack IoT : docker-compose.yml
mongodb: build: ./build/mongodb volumes: - /var/lib/docker/mongo/mongodb:/data/db command: mongod --smallfiles ports: - "27017:27017" mosquitto: image: ansi/mosquitto ports: - "1883:1883" nodered: image: cpswan/node-red volumes: - /var/lib/docker/node-red/:/root/.node-red/ ports: - "1880:1880" links: - mongodb - mosquitto
Exécuter
docker-compose build docker-compose up
Depuis un autre terminal de la machine qui exécute le conteneur Docker (ou depuis une autre machine)
python -m webbrowser -t "http://localhost:1880"
Ajouter le flow suivant via Menu > Import > Clipboard
[{"id":"965143fc.a69178","type":"mqtt-broker","z":"fcf48541.b80728","broker":"test.mosquitto.org","port":"1883","clientid":"","usetls":false,"verifyservercert":true,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willRetain":null,"willPayload":"","birthTopic":"","birthQos":"0","birthRetain":null,"birthPayload":""},{"id":"a1272e5a.1014","type":"mqtt in","z":"fcf48541.b80728","name":"IoT","topic":"fr/imag/air/iot","broker":"965143fc.a69178","x":280,"y":180,"wires":[["c623e440.c45b28","cc911cbf.60d298"]]},{"id":"c623e440.c45b28","type":"file","z":"fcf48541.b80728","name":"","filename":"","appendNewline":true,"createDir":false,"overwriteFile":"false","x":670,"y":180,"wires":[]},{"id":"cc911cbf.60d298","type":"debug","z":"fcf48541.b80728","name":"","active":true,"console":"false","complete":"false","x":680,"y":260,"wires":[]}]
Depuis une autre machine:
mosquitto_pub -h test.mosquitto.org -t fr/imag/air/iot -m "sensor deveui=1234567 temp=20.10;hum=56.0;pres=1013.25;wind=5.0;rainlast10min=5;rainlasthour=10"
Vérifier la récupération du message dans l'onglet Debug de Node-RED.
Arrêt d'une composition
docker-compose stop
Définition de votre propre conteneur
- Dockerfile Reference https://docs.docker.com/engine/reference/builder/
- Best Practices https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/
TODO