pense-bête de bruno sanchiz

Accueil > Virtualisation > Virtualisation : docker

Virtualisation : docker

Publié le 8 avril 2017, dernière mise-à-jour le 26 avril 2021, 3 visites, 23980 visites totales.

Principe : créer un système virtualisé
Moyens :

  1. soit créer un fichier Dockerfile puis docker build . -t nom puis docker run nom
  2. soit télécharger un fichier Dockerfile et l’utiliser docker run debian:stretch voir
  3. soit utiliser une image toute faite :
  4. docker pull ubuntu:trusty

installer docker


commandes très utiles
commandes utiles
exemples de fichiers dockerfile
commandes
installation



commandes utiles :

  • tout virer : docker rm $(docker ps -a -q) ; docker rmi -f $(docker images -q)
  • docker images : liste
  • docker ps : ceux qui tournent
  • docker run -it nom bash lancer avec un bash
  • docker run hello-world : lancer
  • docker container run hello-world : lancer la première fois ??
  • docker rmi 025456af45df : détruire un docker
  • détruire tous les docker :
    • docker rmi $(docker images -q)
      -** docker rmi -f $(docker images -q)
  • import/export image : docker save centos | gzip > MyCentOS.tar.gz ; zcat MyCentOS.tar.gz | docker import – centos:latest
  • import/export container : docker export container8 | gzip > container8.tar.gz ; zcat container8.tar.gz | docker import – container8
  • docker commit 3a09b2588478 mynewimage && docker save mynewimage > /tmp/mynewimage.tar puis docker load < /tmp/mynewimage.tar


commandes utiles :


COMMANDES
docker build -t friendlyname .  # Create image using this directory’s Dockerfile
docker run -p 4000:80 friendlyname  # Run "friendlyname" mapping port 4000 to 80
docker run -d -p 4000:80 friendlyname         # Same thing, but in detached mode
docker ps                                 # See a list of all running containers
docker stop <hash>                     # Gracefully stop the specified container
docker ps -a           # See a list of all containers, even the ones not running
docker kill <hash>                   # Force shutdown of the specified container
docker rm <hash>              # Remove the specified container from this machine
docker rm $(docker ps -a -q)           # Remove all containers from this machine
docker images -a                               # Show all images on this machine
docker rmi <imagename>            # Remove the specified image from this machine
docker rmi $(docker images -q)             # Remove all images from this machine
docker login             # Log in this CLI session using your Docker credentials
docker tag <image> username/repository:tag  # Tag for upload to registry
docker push username/repository:tag            # Upload tagged image to registry
docker run username/repository:tag                   # Run image from a registry


DOCUMENTATIONS
https://fr.wikipedia.org/wiki/Docker_%28logiciel%29
https://linuxfr.org/users/xion345/journaux/docker-la-plateforme-a-la-mode
https://www.wanadev.fr/23-tuto-docker-comprendre-docker-partie1/
https://linuxfr.org/news/docker-tutoriel-pour-manipuler-les-conteneurs
https://putaindecode.io/fr/articles/docker/dockerfile/
https://putaindecode.io/fr/articles/docker/
https://www.tecmint.com/install-run-and-delete-applications-inside-docker-containers/
https://www.ovh.com/fr/blog/docker-administrer-bases-de-donnees-une-idee-folle/

Les images créées sont dans /var/lib/docker/overlay2/

système d(’administration : ansible,puppt...

[bruno sanchiz]