Skip to content

Use awk to get debian/ubuntu/rpi VERSION_CODENAME #22453

Closed
@jreslock

Description

@jreslock

Is this a docs issue?

  • My issue is about the documentation content or website

Type of issue

Information is incorrect

Description

The command used to set up the apt repositories for each of these OS targets is confusing.

In this section:

# Add the repository to Apt sources:
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

The $(. /etc/os-release && echo)...is confusing and unnecessarily invokes echo where we could use a simpler approach to achieve the same result using a simple awk command.

Location

https://docs.docker.com/engine/install/debian/

Suggestion

Use awk to do the same thing and only invoke a single command avoiding having to nest && echo ... inside of an already complicated echo command.

   # Add the repository to Apt sources:
   echo \
     "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] {{% param "download-url-base" %}} \
     $(awk -F= '/VERSION_CODENAME/ { print $2 }' /etc/os-release) stable" | \
     sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
   sudo apt-get update

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions