Skip to content

Latest commit

 

History

History
75 lines (59 loc) · 2.5 KB

File metadata and controls

75 lines (59 loc) · 2.5 KB

Table of Contents

Docker

docker swarm

Attention l'utilisation de docker-compose.yml ne permet pas d'utiliser de fichier .env comme avec docker-compose

Mode mono node

Sans registry, il faut builder les images (`docker build . -t [nom]`)

  • initialisation : `docker swarm init --advertise-addr=[adresse]`
  • m

docker-compose

{NOM DU SERVICE} est optionnel, sans alors tous les services décrits dans docker-compose sont concernés

  • `docker-compose build {NOM DU SERVICE}`
  • `docker-compose up -d {NOM DU SERVICE}`
  • `docker-compose logs {NOM DU SERVICE}`
Le principe : 1. construction de l'image en couche, pour chaque couche une instrcution du dockerfile 2. création du container avec l'image buildé

Chaque modification du dockerfile implique la reconstruction de l'image.

docker

  • create a docker folder
  • edit `Dockerfile`
  • build `sudo docker build -t david/nginx:v1`
  • run the docker `sudo docker run -p 80:80 -d -t david/nginx:v1`
  • quelques commandes :
    - `sudo docker exec -t -i {NAME|CONTAINER_ID} bash` login the container
    - `sudo docker run -d -P -v `pwd`/data/mysql:/var/lib/mysql {REF_NAME}`
    - `sudo docker build --no-cache .`
    - `sudo docker images` list images
    - `sudo docker rmi {ID IMAGE}`

  • TO TEST : https://lebkowski.name/docker-volumes/ (clean up docker to reclaim disk space)
  • `docker volume ls -qf dangling=true | xargs -r docker volume rm` pour effacer touto
  • `docker inspect` pour aller chercher des infos précises

TO DODO

  • [] Voir l'option PID comment çà fonctionne

Example

To write the correct Dockerfile test you have to test some commands so do :

  • run the container in daemon mode :
 `docker run -t ansible/ubuntu14.04-ansible /bin/bash`

  • copy local file needed to docker :
 `cd  /var/lib/docker/aufs/mnt/{ID-CONTAINER} && cp my-ansible etc/ansible`

  • login docker : `docker exec -ti {ID-CONTAINER} /bin/bash`
  • test command

Links