GNU/Linux >> Linux Esercitazione >  >> Ubuntu

Come installare Docker su Ubuntu 16.04

Docker è un software open source che aiuta a distribuire ed eseguire applicazioni in un container. I container sono come una macchina virtuale ma consumano meno risorse, sono facili da gestire e funzioneranno sempre allo stesso modo indipendentemente dall'ambiente operativo in cui è in esecuzione.

Docker utilizza cgroup e namespace per consentire l'esecuzione dei contenitori indipendenti all'interno di una singola istanza Linux.

Questa guida ti aiuterà a installare Docker su Ubuntu 16.04.

Docker richiede un sistema operativo a 64 bit e supporta Ubuntu 16.04 LTS, Ubuntu 18.04 LTS, Ubuntu 18.10 e Ubuntu 19.04.

Installa Docker su Ubuntu 16.04

Docker è ora disponibile in due edizioni,

  • Edizione comunitaria (CE)
  • Edizione Enterprise (EE)

Qui installeremo Docker Comunity Edition (CE).

Prerequisiti

Disinstalla le versioni precedenti di Docker, denominato docker o docker-engine insieme alle dipendenze associate. Se il tuo sistema non dispone di un pacchetto Docker, salta il passaggio seguente.

sudo apt-get -y remove docker.io docker-engine containerd runc

Contenuti come immagini, volumi e reti in /var/lib/docker/ vengono conservati.

Imposta il repository Docker

Aggiorna la cache del repository.

sudo apt-get update

Installa i seguenti pacchetti per assicurarti che apt funzioni con il metodo https e che i certificati CA siano installati.

sudo apt-get install -y apt-transport-https software-properties-common ca-certificates wget

Aggiungi la chiave GPG per il repository Docker sul tuo sistema.

wget https://download.docker.com/linux/ubuntu/gpg 

sudo apt-key add gpg

Ora aggiungi il repository Docker ufficiale eseguendo il seguente comando nel terminale.

echo "deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable" | sudo tee /etc/apt/sources.list.d/docker.list

Aggiorna il database apt.

sudo apt-get update

Assicurati di installare la finestra mobile dal repository ufficiale, non dai repository Ubuntu predefiniti.

sudo apt-cache policy docker-ce

Dovresti vedere l'output come di seguito, dovresti avere i dettagli del repository Docker.

docker-ce:
  Installed: (none)
  Candidate: 5:19.03.5~3-0~ubuntu-xenial
  Version table:
     5:19.03.5~3-0~ubuntu-xenial 500
        500 https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
     5:19.03.4~3-0~ubuntu-xenial 500
        500 https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
     5:19.03.3~3-0~ubuntu-xenial 500
        500 https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages

Installa Docker

Ora installa Docker usando il seguente comando.

sudo apt-get -y install docker-ce

Ora che hai Docker installato sulla tua macchina, avvia il servizio Docker nel caso non venga avviato automaticamente dopo l'installazione

sudo systemctl start docker

sudo systemctl enable docker

Esegui un contenitore Docker per verificare l'installazione Docker

sudo docker run hello-world

Dovresti vedere l'output come di seguito; questo conferma che Docker è installato correttamente.

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete 
Digest: sha256:4fe721ccc2e8dc7362278a29dc660d833570ec2682f4e4194f4ee23e415e1064
Status: Downloaded newer image for hello-world:latest

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://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

Consenti all'utente non root di eseguire Docker

Per impostazione predefinita, è necessario il privilegio di root per eseguire i comandi della finestra mobile. Per evitare ciò, stavo usando i comandi docker con sudo. Se desideri consentire agli utenti non root di eseguire i container Docker, segui i passaggi seguenti per concedere loro i privilegi per eseguire un Docker.

Crea un gruppo chiamato Docker se non esiste.

sudo groupadd docker

Aggiungi il tuo utente al gruppo Docker, sostituisci raj con il tuo nome utente.

sudo useradd -m raj

Aggiungi un utente al gruppo Docker.

sudo usermod -aG docker raj

Esci e riconnettiti.

Ora dovresti essere in grado di eseguire i comandi Docker senza anteporre sudo.

$ docker run hello-world

Argomenti interessati

Argomenti di base di Docker

1:Principali importanti comandi Docker – Utilizzo dei contenitori Docker

2:Utilizzo delle immagini Docker – Creazione di immagini Docker

3:Come creare immagini Docker con DockerFile

Argomenti avanzati di Docker

1:come configurare il registro privato Docker su CentOS 7

2:come installare e configurare Docker Swarm su CentOS 7

Conclusione

È tutto. Per favore condividi i tuoi pensieri nella sezione commenti.


Ubuntu
  1. Come installare Docker su Ubuntu 18.04 / Ubuntu 18.10 / Ubuntu 19.04

  2. Come installare Docker su Debian/Ubuntu

  3. Come installare Docker su Ubuntu 20.04 LTS

  4. Come installare Docker su Ubuntu 18.04?

  5. Come installare Docker su Ubuntu 22.04

Come installare Portainer Docker Manager in Ubuntu 20.04

Come installare Docker su Ubuntu 20.04, 18.04, 21.04

Come installare Docker su Ubuntu 14.04

Come installare Docker su Ubuntu 20.04 LTS

Come installare Wiki.js su Ubuntu 20.04 LTS

Come installare Docker su Ubuntu 18.04