Skip to content

Conversation

@jreslock
Copy link

Description

The installation instructions for Debian, Ubuntu and Raspberry PI all use a complicated $(. /etc/os-release && echo "VERSION_CODENAME") command to set the VERSION_CODENAME for the apt source configuration. It would be much simpler and straightforward to use awk to get this from the target file and pass to the subsequent tee command.

This commit updates the installation instructions for each of the deb-based operating systems to use awk -F '/VERSION_CODENAME' { print $2 } /etc/os-release instead of the current, somewhat confusing and complicated sourcing of the file and subsequent echo to produce the same result using a single command invocation and built-in utility (awk).

Related issues or tickets

I created an issue for this before creating this PR.

#22453

Reviews

  • Technical review
  • Editorial review
  • Product review

@github-actions github-actions bot added area/engine Issue affects Docker engine/daemon area/install Relates to installing a product labels Apr 18, 2025
@netlify
Copy link

netlify bot commented Apr 18, 2025

Deploy Preview for docsdocker ready!

Name Link
🔨 Latest commit 4a4ac41
🔍 Latest deploy log https://app.netlify.com/sites/docsdocker/deploys/68024cb24aeeb5000862522d
😎 Deploy Preview https://deploy-preview-22454--docsdocker.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if we should change this, but happy to hear if there's additional motivations here

echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] {{% param "download-url-base" %}} \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
$(awk -F= '/VERSION_CODENAME/ { print $2 }' /etc/os-release) stable" | \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm.. not sure I understand the change; how is this simpler than a source and echo ? The update also requires awk to be present, which would be in "most" setups, but is not guaranteed.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @thaJeztah! Thank you for reviewing and commenting.

I submitted this PR and related issue because I was having some trouble using these commands in a Dockerfile to install the docker-compose-plugin inside of a devcontainer. My "fix" to use awk seemed to work and I thought it would be helpful for others. I have re-tested locally using the original $(. /etc/os-release && echo "$VERSION_CODENAME") which is now working fine for me. I very likely had some minor syntax issue causing my initial problem.

If this change doesn't make sense or is undesired I will not be offended/upset.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, looking a bit further, this change is definitely not right as it would break if these would have a quote, or otherwise;

awk -F= '/PRETTY_NAME/ { print $2 }' /etc/os-release
"Debian GNU/Linux trixie/sid"

. /etc/os-release && echo $PRETTY_NAME
Debian GNU/Linux trixie/sid

os-release(5) man page also describes sourcing to be the correct way; parsing in other languages is possible, but requires much more handling to make sure the values are properly consumed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depending on your situation, if you need to have just the docker-compose (or docker CLI) in your Dockerfile, you can also use the bin images;

To run it standalone;

# syntax=docker/dockerfile:1

# COMPOSE_VERSION is the version of compose to install in the dev container.
ARG COMPOSE_VERSION=v2.35.1
FROM docker/compose-bin:${COMPOSE_VERSION} AS compose

FROM alpine
COPY --link --from=compose    /docker-compose /usr/local/bin/docker-compose
docker build -t foo .

docker run --rm foo docker-compose version
Docker Compose version v2.35.1

Or if you want other tools (I should warn that the buildx-bin and cli-bin images are mostly for testing purposes, but you can copy from the official docker:cli image as well);

# syntax=docker/dockerfile:1

# DOCKERCLI_VERSION is the version of the docker CLI to install in the dev container.
ARG DOCKERCLI_VERSION=28.1.1

# BUILDX_VERSION is the version of buildx to install in the dev container.
ARG BUILDX_VERSION=0.23.0

# COMPOSE_VERSION is the version of compose to install in the dev container.
ARG COMPOSE_VERSION=v2.35.1

FROM dockereng/cli-bin:${DOCKERCLI_VERSION} AS cli
FROM docker/buildx-bin:${BUILDX_VERSION} AS buildx
FROM docker/compose-bin:${COMPOSE_VERSION} AS compose


FROM alpine

COPY --link --from=cli        /docker         /usr/local/bin/docker
COPY --link --from=buildx     /buildx         /usr/local/libexec/docker/cli-plugins/docker-buildx
COPY --link --from=compose    /docker-compose /usr/local/libexec/docker/cli-plugins/docker-compose
docker build -t bla .

docker run -it --rm foo docker info
Client:
 Version:    28.1.1
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  28c90ea
    Path:     /usr/local/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.35.1
    Path:     /usr/local/libexec/docker/cli-plugins/docker-compose

Server:
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

@jreslock
Copy link
Author

Based on @thaJeztah's comments, this change is not viable or desirable so I am closing the PR and will close the related issue.

@thaJeztah
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/engine Issue affects Docker engine/daemon area/install Relates to installing a product

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants