Now that you know how to create your own web server, I want us to look into web applications. For this we will start with Docker. Now if you know what a Snap package is, well that is basically what Docker is for web applications. Again, we will go for the low-hanging fruit and get you started as fast as I know how. (There is a lengthy install instruction on the docker homepage, but we are taking the easy route - Thanks @fleabite08). I’m going to assume you are using Ubuntu desktop. Installation: Open your terminal and type: sudo apt install docker.io -y Once it has completed, type sudo docker -v
Maintenant que vous savez créer votre propre serveur Web, je voudrais examiner quelques applications Web. Pour cela, nous commencerons avec Docker. Si vous savez ce que c’est qu’un paquet Snap, eh bien, c’est essentiellement ce qu’est Docker pour les applications Web.
À nouveau, nous ferons le plus simple et je vous ferai commencer aussi rapidement que possible. (Il y a une longue instruction pour l’installation sur la page d’accueil de Docker, mais nous allons choisir la facilité – Merci @fleabite08). Je vais supposer que vous utilisez Ubuntu Desktop.
Installation
Ouvrez votre terminal et tapez :
sudo apt install docker.io -y
Quand c’est fini, tapez
sudo docker -v
OK, we have Docker, now what? Well, we need a web application. Something like Redis, but as we are starting out, let’s set our aim lower. Something everyone can appreciate and understand. Docker has a central repository, if you will, for all these application images. Some are public and some are private. You can go look at the images available - https://hub.docker.com - and there will be instructions on how to get them. A quick word: like any public repository, anyone can publish to the docker hub. Try to eyeball official applications, that is, look for the verified publisher and checkmark.
OK, nous avons Docker, et après ? Nous avons besoin d’une application Web. Quelque chose comme Redis, mais puisque nous commençons, ciblons quelque chose de moindre. Quelque chose que tout le monde peut apprécier et comprendre.
Docker a un dépôt central, en quelque sorte, pour toutes les images d’application. Certaines sont publiques et d’autres sont privées. Vous pouvez allez regarder les images qui sont disponibles – https://hub.docker.com – et il y aura des instructions sur comment les obtenir. Petit avertissement : comme tout dépôt public, n’importe qui peut publier des choses sur le hub de Docker. Essayez de reluquer des applications officielles, autrement dit, chercher les rédacteurs vérifiés et cochés.
Let us try it out: Type: sudo docker run docker/whalesay cowsay boo • docker run – is the initialisation command • docker/whalesay - is the image location on docker hub. • cowsay hello – is the message you want to output in the app. So as you can see, it is not difficult. So what happened when you typed the command? Docker looked to see if you already had the application, and then started pulling it from Docker hub.
Essayons-le
Tapez :
sudo docker run docker/whalesay cowsay boo
••docker run est la commande d’initialisation ••docker/whalesay est l’emplacement de l’image dans le hub Docker ••cowsay boo est le message que vous voulez sortir dans l’appli
Comme vous pouvez le constater, ce n’est pas difficile.
Bon. Qu’est-ce qui s’est passé quand vous avez tapé la commande ?
Docker a regardé pour voir si vous aviez l’application déjà et, après, a commencé à la sortir du hub Docker.
Let’s try a basic command, type: docker ps Everyone makes mistakes. On some distros, you cannot log in as root and you will need sudo. Be sure you have sudo or root access. As my container is no longer running, I do not see it with docker ps. I need to tack on -a, to see ALL the containers. This is the thing about containers. They are usually created to do one job, then exit, but you can have applications that continue running. To stop a running container, the keyword is stop. Can you guess the command? Stopping a container requires either its name or its ID. If you look at either, you can see it is a few characters. However, you just need to type enough for it to be unique. In our case, we have only the one, so it is easy, but if you have many, you need to be very careful here. The command: sudo docker stop <the name of YOUR container>
Essayons une commande de base. Tapez :
docker ps
Tout le monde se trompe. Dans certaines distrib. vous ne pouvez pas vous connecter comme root et vous aurez besoin de sudo. Assurez-vous d’avoir l’accès à sudo ou à root. Puisque mon conteneur ne tourne plus, je ne le vois pas avec docker ps. Il faut que j’ajoute -a pour pouvoir voir ALL (tous) les conteneurs. C’est ça le truc avec les conteneurs. Généralement, ils sont créés pour faire une tâche, puis quitter, mais vous pouvez avoir des applications qui continuent à s’exécuter. Pour arrêter un conteneur qui tourne, le mot clé est stop. Pouvez-vous deviner la commande ? Pour pouvoir arrêter un conteneur, il vous faut, soit son nom, soit son ID. Si vous regardez l’un ou l’autre, vous verrez qu’il ne comporte que quelques caractères. Cependant, vous n’avez besoin que d'en taper assez pour qu’il soit unique. Dans notre cas, nous n’en avons qu’un et c’est facile, mais si vous en avez beaucoup, il faut être très attentif. La commande : sudo docker stop <le nom de VOTRE conteneur>
If you were on the ball, you may have noticed in our command output from “docker ps -a” that the status says exited. Now that our container came to life, did its job, and died again, we may be done with it. Time to free up some disk space. To remove a container, the command is rm, just like in the shell. To do this, the container needs to be stopped or exited. Type: sudo docker rm <the name of YOUR container> Though the container is now gone, there is still the locally cached image that you grabbed from Docker hub on your PC, making reinstallation really quick. To see what images are stored on the local machine, use the following command: sudo docker images Just to make sure you do not accidentally delete the image with the rm command, to remove an image, there is a separate command, rmi. You need to make sure that no containers are running off an image, before you remove it. Try it yourself.
Si vous avez bien compris, vous aurez peut-être remarqué dans la sortie de « docker ps -a » que le statut dit quitté.
Maintenant que notre conteneur a revécu, a fait son travail et est mort à nouveau, on a probablement terminé avec. Le moment est venu de créer de l’espace disque libre. Pour enlever un conteneur, la commande est rm, exactement comme dans le shell. Pour ce faire, le conteneur doit être arrêté ou quitté. Tapez :
sudo docker rm <le nom de VOTRE conteneur>
Bien que le conteneur soit maintenant parti, l’image que vous avez récupérée dans le hub Docker reste cachée localement sur votre machine, ce qui rend la réinstallation très rapide. Pour voir les images stockées sur votre machine, utilisez la commande suivante : sudo docker images
Assurez-vous simplement de ne pas supprimer l’image accidentellement avec la commande rm. Pour enlever une image, il y a une commande distincte, rmi. Il faut être certain qu’aucun conteneur ne s’exécute à partir d’une image avant de l’enlever.
Essayez-le vous-même.
If you get an error that it cannot find your image, simply use the ID. Remember what I said earlier of it having to be unique? In my case, I have only the one, so I can type: sudo rmi 6b and it will be removed. Is yours gone yet? We can grab the image again if needed, simply pull it: sudo docker pull docker/whalesay - and it will download it again, without running it. Homework: Grab the Ubuntu image and run it. What happened??? We will discuss this in the next issue. As always, if we are boring you, drop us a line at: misc@fullcirclemagazine.org
Si vous avez un message d’erreur disant que votre image est introuvable, utilisez tout simplement l’ID. Souvenez-vous de ce que j’ai dit plus tôt : il faut qu’elle soit unique. Dans mon cas, il n’y en a qu’une et je peux donc taper : sudo rmi 6b et elle sera enlevée.
La vôtre est déjà partie ?
Nous pouvons récupérer l’image à nouveau si nécessaire, il suffit d’utiliser pull : sudo docker pull docker/whalesay – et elle sera téléchargée à nouveau, sans s’exécuter.
Devoir
Récupérez l’image d'Ubuntu et exécutez-la.
Que s’est-il passé ???
Nous en parlerons dans le prochain numéro.
Comme toujours, si nous vous ennuyons, dites-le-nous avec un mail : misc@fullcirclemagazine.org