skip to Main Content

I started a new class and I am new in using Linux. I use debian and I follow to teacher guide to install git and docker. I entered all the commands in the terminal until I had some error.

  1. sudo apt install git worked

git config --global user.name "Ion Popescu"
git config --global user.email "[email protected]"
git config --global core.editor vim
git config --global core.pager more
git config --global help.autocorrect true 

all worked

  1. sudo apt-get -y remove docker docker-engine docker.io worked

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

worked all of them

5.

wget https://download.docker.com/linux/debian/gpg
sudo apt-key add gpg

worked

  1. echo "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee -a /etc/apt/sources.list.d/docker.list worked

Now I have to enter these lines but I get an error after the first one

7.

sudo apt update
sudo apt-cache policy docker-ce
sudo apt -y install docker-ce

E: Malformed entry 1 in list file /etc/apt/sources.list.d/docker.list (Component)
E: The list of sources could not be read.

How to solve this?

2

Answers


  1. To make sure that /etc/apt/sources.list.d/docker.list is formatted correctly use the following command (tee without -a to override the source):

    On debian Buster:

    printf "%sn" "deb [arch=amd64] https://download.docker.com/linux/debian buster stable" |
    sudo tee /etc/apt/sources.list.d/docker.list
    

    On debian Stretch:

    printf "%sn" "deb [arch=amd64] https://download.docker.com/linux/debian stretch stable" |
    sudo tee /etc/apt/sources.list.d/docker.list
    

    (You can use $(lsb_release -cs) instead of debian codename which require lsb-release package to be installed.)

    An alternative way to add docker-ce repository: You have already installed software-properties-common, you can use add-apt-repository to add the repository:

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

    Docker-ce docs

    Login or Signup to reply.
  2. Try this, it worked for me :

    echo 
      "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu 
      focal stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null`
    

    The problem is with the variable $(lsb_release -cs), in linux it returns something like una (at least on Mint 20.3). I don’t think there is a special repository for mint so you must hard code it. I was following the official doc, but also read this forum where it was mentioned that you also need to delete the current docker list available in /etc/apt/sources.listd/docker.list.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search