Skip to content

Instantly share code, notes, and snippets.

@jfollenfant
Last active August 21, 2017 14:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save jfollenfant/31b81bcc01e92da83a35b2cdbaceb174 to your computer and use it in GitHub Desktop.
Save jfollenfant/31b81bcc01e92da83a35b2cdbaceb174 to your computer and use it in GitHub Desktop.
# Check docker install
docker version
# check docker first run hello world
docker run hello-world
# Répertoire de travail
mkdir oxademo ; cd oxademo
# hello.php
<?php echo “hello from Oxalide\n”; ?>
# Dockerfile
FROM debian
MAINTAINER jfollenfant <jfo@oxalide.com>
ADD ./hello.php /
RUN apt-get update
RUN apt-get -y install php5-cli
CMD php /hello.php && echo $ENV
# Build de notre première image
docker build -t hello-oxa .
# On vérifie le build de notre image
docker images
# Premier run de notre image
docker run --name "demo1" hello-oxa
# On constate que notre container ne tourne plus, il est arrivé au bout de son execution
docker ps ; docker ps -a
# On détruit relance un docker run pour instancier une deuxième fois notre image avec une variable d'env
docker run -e ENV=demo --name "demo2" hello-oxa
# On relance une nouvelle fois notre premier container en mode interfactif pour avoir la sortie stdin cette fois
docker start -i demo1
# On test avec une variable d'env sur demo2
docker start -i demo2
# Puis on détruit nos deux containers
docker rm demo1 demo2
# Puis on fait le ménage dans les images
docker rmi hello-oxa
# On créé un cluster elasticsearcha avec un premier noeud
docker run -d --name es-01 -p 9201:9200 -d elasticsearch:1.7.5 elasticsearch -Des.node.name=”es-01”
# On vérifie la présence du container en état running et l'état du cluster ES
docker ps
curl http://192.168.99.100:9200/_cluster/health?pretty=true
# Oups ! Mauvais port car on a mappé 9201 vers le 9200 à l'intérieur du container
curl http://192.168.99.100:9201/_cluster/health?pretty=true
# On ajoute deux nouveaux noeuds pour constituer le cluster ES :
docker run -d --name es-02 -p 9202:9200 -d elasticsearch:1.7.5 elasticsearch -Des.node.name=”es-02”
docker run -d --name es-03 -p 9203:9200 -d elasticsearch:1.7.5 elasticsearch -Des.node.name=”es-03”
# On vérifie l'état des containers à nouveau
docker ps
# Puis l'état du cluster ES
curl http://192.168.99.100:9201/_cluster/health?pretty=true
# On installer un plugin d'admin plus convivial à l'intérieur d'un des containers qui tourne déjà
docker exec -it es-01 plugin install lmenezes/elasticsearch-kopf/v1.6.1
# On accède à l'inteface via http://192.168.99.100:9201/_plugin/kopf
On créé un index ES via l'interface en question via une méthode POST
# On arrête un des noeuds ES 02 ou 03
docker stop es-02
# On check à nouveau la santé du cluster ES
curl http://localhost:9201/_cluster/health?pretty=true
# Puis on le relance
docker start es-02
# On regarde la composition du Dockerfile Elasticsearch utilisé avec l'instruction VOLUME, permettant de faire persister les données
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment