Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»Linux Distributions»Debian»How to Install Docker on Debian 9 (Stretch)

    How to Install Docker on Debian 9 (Stretch)

    RahulBy RahulAugust 4, 20183 Mins ReadUpdated:December 13, 2018

    Docker is a container-based application framework, which wraps a specific application with all its dependencies in a container. Docker containers can easily to ship to the remote location on start there without making entire application setup. This tutorial will help you to install Docker on Debian 9 Stretch.

    Step 1 – Prerequsites

    The very first step is to remove any default Docker packages from the system before installation Docker on a Linux VPS. Execute commands to remove unnecessary Docker versions.

    sudo apt-get purge docker lxc-docker docker-engine docker.io
    

    Now install some required packages on your system for installing Docker on Debian system. Run the below commands to do this:

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

    Step 2 – Setup Docker Repository

    Now import dockers official GPG key to verify packages signature before installing them with apt-get. Run the below command on terminal.

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

    After that add the Docker repository on your Debian system which contains Docker packages including its dependencies. You must have to enable this repository to install Docker on Debian.

    sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian stretch stable"
    

    Step 3 – Install Docker on Debian 9

    Your system is now ready for Docker installation. Run the following commands to upgrade apt index and then install Docker community edition on Debian.

    sudo apt-get update
    sudo apt-get install docker-ce
    

    After successful installation of Docker community edition, the service will start automatically, Use below command to verify service status.

    sudo systemctl status docker
    

    Your system is now ready for running Docker containers. Use our Docker Tutorial for Beginners to working with Docker.

    Step 4 – How to Use Docker

    After installation of Docker on a Linux. Here are some basic details for search and download Docker images, launch containers and manage them.

    Search Docker Images

    First of all search Docker container images from Docker hub. For example, below command will search all images with Debian and list as output.

    docker search debian
    

    Download Docker Images

    Now download the Docker container with name debian on your local system using following commands.

    docker pull debian
    
    Using default tag: latest
    latest: Pulling from library/debian
    55cbf04beb70: Pull complete
    Digest: sha256:f1f61086ea01a72b30c7287adee8c929e569853de03b7c462a8ac75e0d0224c4
    Status: Downloaded newer image for debian:latest
    

    Now make sure that the above images have been downloaded successfully on your system. Below command list all images.

    docker images
    
    REPOSITORY    TAG          IMAGE ID            CREATED         SIZE
    debian        latest       3bbb526d2608        4 weeks ago     101MB
    

    Launch New Container with Image

    Finally, launch a Docker container using an above-downloaded image on your system. Below command will start a new container and provide you access to that container with /bin/bash shell.

    docker run -i -t debian /bin/bash
    

    To exit from docker container type CTRL + P + Q. This will leave container running in the background an provide you host system console. If you used the exit command, it will stop the current container.

    After exiting from Docker container, execute below command to list all running containers.

    docker ps
    
    CONTAINER ID     IMAGE     COMMAND        CREATED        STATUS        PORTS    NAMES
    f2582758af13     debian    "/bin/bash"    2 hours ago    Up 2 hours             first_debian
    

    By default Above command will list only running containers. To list all containers (including stopped container) use the following command.

    docker ps -a
    

    Start/Stop/Attach Container

    You can start, stop or attach to any containers with following commands. To start container use following command.

    docker start <CONTAINER_ID>
    

    To stop container use following command.

    docker stop <CONTAINER_ID>
    

    To attach to currently running container use following command.

    docker attach <CONTAINER_ID>
    
    Debian 9 Docker
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
    Previous ArticleHow to Convert VDI to VMDK Disk using VirtualBox
    Next Article How To Install Wine 3 on Debian 8 (Jessie)

    Related Posts

    How to Create a Sudo User in Debian

    Updated:June 26, 20212 Mins Read

    How To Install XRDP (Remote Desktop) on Debian 10

    4 Mins Read

    Initial Server Setup with Debian 10/9/8

    Updated:June 25, 20214 Mins Read

    How to Install Docker Compose on Ubuntu 20.04

    4 Mins Read

    How To Install and Configure VNC Server on Debian 10

    Updated:June 26, 20215 Mins Read

    How to Install TeamViewer on Debian 10

    3 Mins Read

    4 Comments

    1. Shashi Kiran on September 3, 2019 12:23 pm

      In Step 1:

      I got this message :
      ..
      ..
      == Cut and Paste ==
      Do you want to continue? [Y/n] Y
      Err:1 http://raspbian.raspberrypi.org/raspbian stretch/main armhf gnupg2 all 2.1.18-8~deb9u3
      404 Not Found [IP: 2a00:1098:0:80:1000:75:0:3 80]
      E: Failed to fetch http://raspbian.raspberrypi.org/raspbian/pool/main/g/gnupg2/gnupg2_2.1.18-8~deb9u3_all.deb 404 Not Found [IP: 2a00:1098:0:80:1000:75:0:3 80]
      E: Unable to fetch some archives, maybe run apt-get update or try with –fix-missing?

      ==X== End Cut and Paste ==X==

      I had done the sudo apt-get before I tried this above.

      $ lsb_release -cs
      stretch
      [email protected]:~ $ lsb_release -ca
      No LSB modules are available.
      Distributor ID: Raspbian
      Description: Raspbian GNU/Linux 9.4 (stretch)
      Release: 9.4
      Codename: stretch

      =======

      $ cat /etc/apt/sources.list
      deb http://raspbian.raspberrypi.org/raspbian/ stretch main contrib non-free rpi
      # Uncomment line below then ‘apt-get update’ to enable ‘apt-get source’
      #deb-src http://raspbian.raspberrypi.org/raspbian/ stretch main contrib non-free rpi

      Reply
    2. Zer00CooL on December 10, 2018 12:12 pm

      debain or debian ?

      sudo add-apt-repository “deb [arch=amd64] https://download.docker.com/linux/debain stretch stable”

      sudo add-apt-repository “deb [arch=amd64] https://download.docker.com/linux/debian stretch stable”

      Reply
      • Rahul on December 13, 2018 9:55 am

        Thanks dear, I have correct typo.

        Reply
    3. hamed shirvani on August 19, 2018 10:26 am

      hi

      thanks from this post, please help to install openstack with single server

      Reply

    Leave A Reply Cancel Reply

    Recent Posts
    • How to Install Ionic Framework on Ubuntu 22.04
    • What is the /etc/hosts file in Linux
    • How to Install Angular CLI on Ubuntu 22.04
    • How to Install Composer on Ubuntu 22.04
    • How to Create DMARC Record For Your Domain
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.