Skip to main content

Installation de Docker en ligne de commande

The Docker installation package available in the official Debian repository may not be the latest version. To ensure we get the latest version, we’ll install Docker from the official Docker repository. To do that, we’ll add a new package source, add the GPG key from Docker to ensure the downloads are valid, and then install the package.

First, update your existing list of packages:


    sudo apt update
    
    

    Next, installInstall a few prerequisite packages which let apt use packages over HTTPS:

    sudo 
    apt
      sudo apt install apt-transport-https ca-certificates curl gnupg2 software-properties-common


      Then add the GPG key for the official Docker repository to your system:

      curl 
        curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
        
        


        Add the Docker repository to APT sources:

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


          Next, update the package database with the Docker packages from the newly added repo:

          sudo apt update
            sudo apt update
            
            


            Make sure you are about to install from the Docker repo instead of the default Debian repo:

            
            
              apt-cache policy docker-ce
              
              


              You’ll see output like this, although the version number for Docker may be different:

              Output of apt-cache policy docker-ce
              docker-ce:
                Installed: (none)
                Candidate: 5:20.10.12~3-0~debian-buster
                Version table:
                   5:20.10.12~3-0~debian-buster 500
                      500 https://download.docker.com/linux/debian buster/stable amd64 Packages
              

              Notice that docker-ce is not installed, but the candidate for installation is from the Docker repository for Debian 10 (buster).

              Finally, install Docker:

              sudo 
              apt
                sudo apt install docker-ce
                
                


                Docker is now installed, the daemon started, and the process enabled to start on boot. Check that it’s running:

                
                
                  sudo systemctl status docker
                  
                  


                  The output will be similar to the following, showing that the service is active and running:

                  
                  
                  Output
                  ● docker.service - Docker Application Container Engine
                     Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
                     Active: active (running) since Mon 2019-07-08 15:11:19 UTC; 58s ago
                       Docs: https://docs.docker.com
                   Main PID: 5709 (dockerd)
                      Tasks: 8
                     Memory: 31.6M
                     CGroup: /system.slice/docker.service
                             └─5709 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
                  

                  Installing Docker gives you not just the Docker service (daemon) but also the docker command line utility, or the Docker client. We’ll explore how to use the docker command later in this tutorial.