Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MrTrustor/227209f05cd2a997900c2118f332984f to your computer and use it in GitHub Desktop.
Save MrTrustor/227209f05cd2a997900c2118f332984f 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 demo && cd demo
# hello.php
echo '<?php echo "hello from Oxalide\n"; ?>' > hello.php
# Dockerfile
cat <<EOT > Dockerfile
FROM debian
ADD ./hello.php /
RUN apt-get update
RUN apt-get -y install php-cli
CMD php /hello.php && echo $ENV
EOT
# 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://127.0.0.1:9200/_cluster/health?pretty=true
# Oups ! Mauvais port car on a mappé 9201 vers le 9200 à l'intérieur du container
curl http://127.0.0.1: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://127.0.0.1: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://127.0.0.1:9201/_plugin/kopf
curl -X POST http://127.0.0.1:9201/test-demo
# 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
# https://github.com/docker-library/elasticsearch/blob/ca669a81afb503dedac6ba1bb8bef2abc158f081/1.7/Dockerfile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment