Docker sur Mac

Docker sur Mac

docker fonctionne uniquement sur un noyau linux. Pour le faire marcher sur un OS X, on utilise un machine virtuelle exécutant un linux léger. Pour gérer cette machine virtuelle, on utilise un utilitaire appelé boot2docker.

Pour l’installer :

➜ k ~  brew install boot2docker docker

Après on récupère la dernière ISO :

➜ k ~  boot2docker download

Et on initialise la VM utilisée pour faire tourner le daemon docker et on la faire démarrer :

 k ~  boot2docker init 
Generating public/private rsa key pair.
 
<snip>

 k ~  boot2docker up
Waiting for VM and Docker daemon to start...
.............................................
Started.

To connect the Docker client to the Docker daemon, please set:
    export DOCKER_HOST=tcp://192.168.59.103:2375

On positionne la variable d’environnement DOCKER_HOST :

➜ k ~  export DOCKER_HOST=tcp://192.168.59.103:2375

Puis on teste notre installation en exécutant :

 k ~  docker run hello-world
Unable to find image 'hello-world' locally
Pulling repository hello-world
565a9d68a73f: Download complete 
511136ea3c5a: Download complete 
2505d942a91d: Download complete 
Hello from Docker.
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (Assuming it was not already locally available.)
3. The Docker daemon created a new container from that image which runs the
     executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
        to your terminal.

To try something more ambitious, you can run an Ubuntu container with:  $ docker run -it ubuntu bash

For more examples and ideas, visit:
http://docs.docker.com/userguide/

Après, on utilise docker de façon classique, j’y reviendrai dans d’autres billets.