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, 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