Docker CE su Ubuntu 16.04.3

Considerando un sistema server Ubuntu 16.04.3 già installato, vi consiglio di leggere l’articolo qui riportato.

Installiamo Docker CE ( Community Edition ) con qualche esempio di utilizzo.

Aggiorniamo i pacchetti presenti nel nostro sistema ed aggiungiamo il repository adatto per Ubuntu:

sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

Per le architetture a 64 bit, dovremo aggiungere il seguente repository stabile:

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update

a questo punto installiamo Docker CE:

apt-get install docker-ce

Installato il docker engine, proviamo ad installare e ad avviare un container. Collegandoci al repository Docker Hub,  e scarichiamo localmente un’immagine di esempio:

sudo docker pull hello-world

root@ubuntu:~# sudo docker pull hello-world
Using default tag: latest
latest: Pulling from library/hello-world
ca4f61b1923c: Pull complete
Digest: sha256:be0cd392e45be79ffeffa6b05338b98ebb16c87b255f48e297ec7f98e123905c
Status: Downloaded newer image for hello-world:latest

controlliamo se è stata scaricata

sudo docker images

REPOSITORY     TAG      IMAGE ID                CREATED            SIZE
hello-world           latest   f2a91732366c     2 weeks ago       1.85kB

sudo docker run hello-world

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.
(amd64)
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

Share images, automate workflows, and more with a free Docker ID:
https://cloud.docker.com/

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

A questo punto supponiamo di considerare l’immagine docker di ubuntu e di voler accedere all’interno del contenitore:

sudo docker run -it ubuntu bash

avremo il seguente output e l’accesso al contenitore tramite shell

root@ubuntu:~# docker run -it ubuntu bash
Unable to find image ‘ubuntu:latest’ locally
latest: Pulling from library/ubuntu
660c48dd555d: Pull complete
4c7380416e78: Pull complete
421e436b5f80: Pull complete
e4ce6c3651b3: Pull complete
be588e74bd34: Pull complete
Digest: sha256:7c67a2206d3c04703e5c23518707bdd4916c057562dd51c74b99b2ba26af0f79
Status: Downloaded newer image for ubuntu:latest
root@7edaf537f686:/#

per uscire dal contenitore e tornare all’host fare exit.

Potrebbero interessarti anche...

Utilizzando il sito, accetti l'utilizzo dei cookie da parte nostra. maggiori informazioni

Questo sito utilizza i cookie per fornire la migliore esperienza di navigazione possibile. Continuando a utilizzare questo sito senza modificare le impostazioni dei cookie o cliccando su "Accetta" permetti il loro utilizzo.

Chiudi