Toutes les commandes sont a exécuter en root.
apt-get install docker docker.io
Définititon des images portables = Dockerfile = définition des appli + dépendances + config
vi Dockerfile
docker build -t <tag> . docker images docker images ==> aufs /dev/sda7 on / type xfs (rw,noatime,attr2,inode64,noquota) /dev/sda7 on /var/lib/docker/aufs type xfs (rw,noatime,attr2,inode64,noquota)
Run the app, mapping your machine’s port 4000 to the container’s EXPOSEd port 80 using -p:
Met en évidence la différence entre Publish et Expose
docker run -p 4000:80 friendlyhello docker ps
docker login
docker tag IMAGE[:TAG] IMAGE[:TAG] docker tag friendlyhello liberasys/get-started:part1 docker push liberasys/get-started:part1
Installation sur debian stretch : https://linuxconfig.org/how-to-install-docker-engine-on-debian-9-stretch-linux
Déployer :
docker login docker run liberasys/get-started:part1
Gère les services, fichier docker-compose.yml
vi docker-compose-test.yml docker swarm init docker swarm join --token SWMTKN-1-0hruyzw7aj659s82d4rzw2ypxh0ycxbj3lk2gpei7kkgjjwycc-ebkxd2ol5r8xospv7b0z9v3sm 163.172.126.100:2377 docker stack deploy -c docker-compose.yml <app name> docker stack deploy -c docker-compose.yml getstartedlab docker ps docker stack ps getstartedlab vi docker-compose-test.yml # changer le nombre d'instances docker stack deploy -c docker-compose.yml getstartedlab docker stack ps getstartedlab
Le nombre de containers est mis à jour, sans tout redémarrer !
docker stack rm getstartedlab
docker node ls
docker swarm leave --force
Il faut installer la machine binaire docker
apt-get install curl curl -L https://github.com/docker/machine/releases/download/v0.12.0/docker-machine-`uname -s`-`uname -m` >/tmp/docker-machine && \ chmod +x /tmp/docker-machine && \ sudo cp /tmp/docker-machine /usr/local/bin/docker-machine docker-machine version
cd /root mkdir docker-machine-scripts cd docker-machine-scripts wget "https://github.com/docker/machine/raw/master/contrib/completion/bash/docker-machine-prompt.bash" wget "https://github.com/docker/machine/raw/master/contrib/completion/bash/docker-machine-wrapper.bash" wget "https://github.com/docker/machine/raw/master/contrib/completion/bash/docker-machine.bash" cd /root echo "source /root/docker-machine-scripts/docker-machine.bash" >> .bashrc echo "source /root/docker-machine-scripts/docker-machine-wrapper.bash" >> .bashrc echo "source /root/docker-machine-scripts/docker-machine-prompt.bash" >> .bashrc echo "PS1='\${debian_chroot:+(\$debian_chroot)}\\h:\\w_\$(__docker_machine_ps1)\\$ '" >> .bashrc source .bashrc
docker-machine rm <machine-name> docker-machine rm -f $(docker-machine ls -q)
docker swarm init # sur le premier noeud docker swarm joinn # sur les autres noeuds
docker-machine create --driver virtualbox myvm1 docker-machine create --driver virtualbox myvm2