Error: Malformed entry 1 in list file... when trying to update after setting up repository

I am new to Ubuntu and Docker. Trying to install Docker in Ubuntu 22.04 LTS using Virtual Box. Following instructions for Docker’s apt repository method at docker web site for ubuntu.

I think the problem is in the step to set up the repository. The code for this step is:

"> echo \

“deb [arch=”$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker/gpg] Index of linux/ubuntu/
“$(. /etc/os-release && echo “UBUNTU_CODENAME”)” stable " |
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null"

I get no response from this, which, I think, suggests it worked without exception.

Then I run sudo apt upgrade and it gives me the following error:

“Malformed entry 1 in list file /etc/apt/sources.list.d/docker.list([option] not assignment)
The list of sources could not be read”

I think the error is in this step, but since I am copying it directly out of the instructions on docker.com, I have no idea how to resolve and could not find it listed as a problem on this site. Please advise. Thanks in advance.

don’t forget the $ before UBUNTU_CODENAME as to read $UBUNTU_CODENAME

it’s reading it as a variable and bash reads words that start with $ as a variable

1 Like

cd …/ until you see :/$
cd into this “/etc/apt/sources.list.d”
then at the that point type "sudo rm docker.list "
now use this command “sudo apt-get update”
Now follow this tutorial instead of the one you’re on →

You may also have to install new dependencies based on your setup.
That’s what I did as well as install recommended add on deps. Such as:
libc6:armhf, moby-containerd:armhf, libdb1-compat

I did this and it worked for me

1 Like

Perfect, much easier. Thank you.