Getting started with Docker
  1. Update your existing list of packages and install the perquisites:

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

  2. Add the GPG key for the official Docker repository to your system:

    curl -fsSL | sudo apt-key add -

  3. Add the Docker repository to APT sources:

    sudo add-apt-repository "deb [arch=amd64] $(lsb_release -cs) stable"

  4. Update the package database with the Docker packages from the newly added repo:

    sudo apt update

  5. Install Docker:

    sudo apt install docker-ce
    sudo systemctl status docker

  6. Add your user to the docker group. Log out and back in to apply the changes:

    sudo usermod -aG docker ${USER}

  7. Check the latest Docker Compose version here (currently 1.27.4) and run the following command accordingly:

    sudo curl -L`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
    sudo chmod +x /usr/local/bin/docker-compose

  8. Verify the installation was successful:

    docker-compose --version

  9. Try creating your first container with Docker Compose:

    mkdir hello-world && cd hello-world && nano docker-compose.yml

    Copy and paste the following into the file:

     image: hello-world

  10. Create the container (if there’s no local image named hello-world, it will pull the image from the Docker Hub public repository), attach, and run the program:

    docker-compose up -d

  11. Show all existing Docker containers:

    docker ps -a

  12. Stop and remove all Docker containers:

    docker stop $(docker ps -a -q)
    docker rm $(docker ps -a -q)