Docker : le seizième pas.

Attention ceci est mon brouillon avant de faire une belle documentation sur Docker (il y a à boire et à manger).

Maintenant je vais faire un test avec GitHub : https://github.com . D’abord il faut créer un compte farias06 :

Capture d’écran 2016-05-02 à 15.58.48

Ensuite on fait un projet, pour la part c’est hello_world :

Capture d’écran 2016-05-02 à 16.01.07

Et maintenant il va falloir mettre les sources :

Capture d’écran 2016-05-02 à 16.01.34

Sur le serveur on installe git :

[root@localhost ~]# yum install git
Modules complémentaires chargés : ulninfo
dockerrepo                                                                                                                      | 2.9 kB  00:00:00     
ol7_UEKR3                                                                                                                       | 1.2 kB  00:00:00     
ol7_UEKR4                                                                                                                       | 1.2 kB  00:00:00     
ol7_latest                                                                                                                      | 1.4 kB  00:00:00     
(1/4): ol7_UEKR4/x86_64/updateinfo                                                                                              |  14 kB  00:00:00     
(2/4): ol7_UEKR4/x86_64/primary                                                                                                 | 2.5 MB  00:00:04     
(3/4): ol7_latest/x86_64/updateinfo                                                                                             | 816 kB  00:00:05     
(4/4): ol7_latest/x86_64/primary                                                                                                |  16 MB  00:00:24     
ol7_UEKR4                                                                                                                                        77/77
ol7_latest                                                                                                                                 14274/14274
Résolution des dépendances
--> Lancement de la transaction de test
---> Le paquet git.x86_64 0:1.8.3.1-6.el7_2.1 sera installé
...
Installé :
  git.x86_64 0:1.8.3.1-6.el7_2.1                                                                                                                       

Dépendances installées :
  libgnome-keyring.x86_64 0:3.8.0-3.el7            perl.x86_64 4:5.16.3-286.el7                   perl-Carp.noarch 0:1.26-244.el7                     
  perl-Encode.x86_64 0:2.51-7.el7                  perl-Error.noarch 1:0.17020-2.el7              perl-Exporter.noarch 0:5.68-3.el7                   
  perl-File-Path.noarch 0:2.09-2.el7               perl-File-Temp.noarch 0:0.23.01-3.el7          perl-Filter.x86_64 0:1.49-3.el7                     
  perl-Getopt-Long.noarch 0:2.40-2.el7             perl-Git.noarch 0:1.8.3.1-6.el7_2.1            perl-HTTP-Tiny.noarch 0:0.033-3.el7                 
  perl-PathTools.x86_64 0:3.40-5.el7               perl-Pod-Escapes.noarch 1:1.04-286.el7         perl-Pod-Perldoc.noarch 0:3.20-4.el7                
  perl-Pod-Simple.noarch 1:3.28-4.el7              perl-Pod-Usage.noarch 0:1.63-3.el7             perl-Scalar-List-Utils.x86_64 0:1.27-248.el7        
  perl-Socket.x86_64 0:2.010-3.el7                 perl-Storable.x86_64 0:2.45-3.el7              perl-TermReadKey.x86_64 0:2.30-20.el7               
  perl-Text-ParseWords.noarch 0:3.29-4.el7         perl-Time-HiRes.x86_64 4:1.9725-3.el7          perl-Time-Local.noarch 0:1.2300-2.el7               
  perl-constant.noarch 0:1.27-2.el7                perl-libs.x86_64 4:5.16.3-286.el7              perl-macros.x86_64 4:5.16.3-286.el7                 
  perl-parent.noarch 1:0.225-244.el7               perl-podlators.noarch 0:2.5.1-3.el7            perl-threads.x86_64 0:1.87-4.el7                    
  perl-threads-shared.x86_64 0:1.43-6.el7          rsync.x86_64 0:3.0.9-17.el7                   

Terminé !
[root@localhost ~]# mkdir git
[root@localhost ~]# cd git/
[root@localhost git]# git init
Initialized empty Git repository in /root/git/.git/
[root@localhost git]# echo "# hello_world" >> README.md
[root@localhost git]# git add README.md
[root@localhost git]# git commit -m "first commit"
[master (root-commit) 666b78d] first commit
 Committer: root <root@localhost.localdomain>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:

    git config --global user.name "Your Name"
    git config --global user.email you@example.com

After doing this, you may fix the identity used for this commit with:

    git commit --amend --reset-author

 1 file changed, 1 insertion(+)
 create mode 100644 README.md
[root@localhost git]# git remote add origin https://github.com/farias06/hello_world.git
[root@localhost git]# git push -u origin master
Username for 'https://github.com': farias06
Password for 'https://farias06@github.com': 
Counting objects: 3, done.
Writing objects: 100% (3/3), 221 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/farias06/hello_world.git
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.
[root@localhost git]# git config --global user.name "ARIAS Frederic"
[root@localhost git]# git add server8.c 
[root@localhost git]# git commit -m "My Server"
[root@localhost git]# git push -u origin master
Username for 'https://github.com': farias06
Password for 'https://farias06@github.com': 
Counting objects: 4, done.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 4.08 KiB | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/farias06/hello_world.git
   666b78d..0ad8bd2  master -> master
Branch master set up to track remote branch master from origin.

Et maintenant on regarde sur l’interface si le source est disponible :

Capture d’écran 2016-05-02 à 16.24.43

Mon source est maintenant accessible du monde entier : hello_world/server8.c (https://github.com/farias06/hello_world/blob/master/server8.c). Le début de la célébrité 😉 .

Sinon on peut rester avec son SVN, voir même son CVS. Quel est le rapport entre GITHUB et Docker ? Le rapport c’est « Automated Build » (construction automatique) !

La seconde étape est donc la création d’un compte sur https://hub.docker.com/register/ .

Capture d’écran 2016-05-02 à 16.50.42 Capture d’écran 2016-05-02 à 16.51.07 Capture d’écran 2016-05-02 à 16.52.55

La prochaine étape c’est le push de l’image, et ensuite c’est la construction automatique.

[root@localhost git]# docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: farias06
Password: 
Login Succeeded
[root@localhost git]# docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
dc75f255cd90        my-server7          "/sbin/server8"          2 hours ago         Up 2 hours          0.0.0.0:8087->80/tcp     my-server7-2
1f84fca3adf1        my-server7          "/sbin/server8"          2 hours ago         Up 2 hours          0.0.0.0:8086->80/tcp     my-server7-1
51b94f30c07e        my-haproxy-v15      "/docker-entrypoint.s"   7 hours ago         Up 2 hours          0.0.0.0:80->80/tcp       mon-haproxy-v15c
2fc533c55725        postgres            "/docker-entrypoint.s"   46 hours ago        Up 46 hours         0.0.0.0:5432->5432/tcp   postgres2
[root@localhost git]# docker commit -m "Added server8" -a "ARIAS Frederic" dc75f255cd90 farias06/hello_docker 
sha256:ac157ca4e8b0e475960a4e07c8711a850a9fd69ffc5e209dcd096a51d4e0d809
[root@localhost git]# docker images
REPOSITORY                   TAG                 IMAGE ID            CREATED                  SIZE
ubuntu                       latest              44776f55294a        Less than a second ago   120.1 MB
farias06/hello_docker        latest              ac157ca4e8b0        2 minutes ago            367.4 MB
my-server7                   latest              2dbb7ecbdaa1        4 hours ago              367.4 MB
                                     b3b4e7faef2f        11 hours ago             367.4 MB

Oups j’ai du oublier de mettre la version ..

[root@localhost git]# docker commit -m "Added server8" -a "ARIAS Frederic" dc75f255cd90 farias06/hello_docker:v1
sha256:84198751afa71e272d561ea6a812bc7dec697f5663f0fa5047d7589118e6d6ab
[root@localhost git]# docker search farias06
NAME      DESCRIPTION   STARS     OFFICIAL   AUTOMATED
[root@localhost git]# docker images
REPOSITORY                   TAG                 IMAGE ID            CREATED                  SIZE
ubuntu                       latest              44776f55294a        Less than a second ago   120.1 MB
farias06/hello_docker        v1                  84198751afa7        About a minute ago       367.4 MB
...
[root@localhost git]# docker push farias06/hello_docker
The push refers to a repository [docker.io/farias06/hello_docker]
678521444a2e: Pushed 
a6cb83a08571: Pushed 
3bf1eecb904c: Pushed 
4f9e31a2233f: Pushed 
5f70bf18a086: Mounted from library/haproxy 
latest: digest: sha256:aaa7bf86b55ebd72b44f9d4b8141c18dc1f38fcb7c5b9748d165a3981cff083b size: 4834
678521444a2e: Layer already exists 
a6cb83a08571: Layer already exists 
3bf1eecb904c: Layer already exists 
4f9e31a2233f: Layer already exists 
5f70bf18a086: Layer already exists 
v1: digest: sha256:d91b2bfa33c6579b2a38a6504b836829edd753466da497f425be6e6af9e15a1f size: 4830
[root@localhost git]# docker search farias06
NAME                    DESCRIPTION    STARS     OFFICIAL   AUTOMATED
farias06/hello_docker   Hello Docker   1   

Si je regarde l’interface de Docker, j’ai bien la version v1 et la dernière version .

Capture d’écran 2016-05-02 à 17.24.01

Maintenant le monde entier peut avoir accès à mon image via : docker pull farias06/hello_docker

A noter que l’interface Docker permet de faire de PUSH, et donc de déclencher des actions sur d’autres sites.

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Time limit is exhausted. Please reload CAPTCHA.