I faced the issue while running Docker file- ignoring apt-sources.list URL - #70
I faced the issue while running Docker file- ignoring apt-sources.list URL#70atishthkr321 wants to merge 2 commits into
Conversation
WalkthroughThe Dockerfile was updated to modify the Debian sources list, replacing all HTTP URLs with HTTPS before running system package updates and installations. This ensures that package sources use secure connections during the build process. Changes
Poem
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
| RUN sed -i 's|http://deb.debian.org|https://deb.debian.org|g' /etc/apt/sources.list.d/debian.sources \ | ||
| && apt-get update \ | ||
| && apt-get upgrade -y \ | ||
| && apt-get install -y gcc default-libmysqlclient-dev pkg-config \ |
There was a problem hiding this comment.
🛠️ Refactor suggestion
sed path can break the build; consolidate the RUN layer for robustness & smaller images
The build will fail on any Debian-based image that does not ship /etc/apt/sources.list.d/debian.sources (e.g. older slim tags) because sed exits non-zero when the file is missing.
While you are touching this layer, you can also:
- Skip the unnecessary
apt-get upgrade –y(bloats the image, hurts reproducibility). - Install with
--no-install-recommendsto keep the image lean. - Collapse commands into a single
RUNto reduce layers and make the cleanup unconditional.
Proposed patch:
-RUN sed -i 's|http://deb.debian.org|https://deb.debian.org|g' /etc/apt/sources.list.d/debian.sources \
- && apt-get update \
- && apt-get upgrade -y \
- && apt-get install -y gcc default-libmysqlclient-dev pkg-config \
- && rm -rf /var/lib/apt/lists/*
+RUN set -eux; \
+ # Switch any Debian mirrors to HTTPS if the file exists (works on older & newer images)
+ for f in /etc/apt/sources.list /etc/apt/sources.list.d/debian.sources; do \
+ [ -f "$f" ] && sed -i 's|http://deb.debian.org|https://deb.debian.org|g' "$f"; \
+ done; \
+ apt-get update; \
+ apt-get install -y --no-install-recommends gcc default-libmysqlclient-dev pkg-config; \
+ rm -rf /var/lib/apt/lists/*This keeps the build portable, reproducible, and slimmer without changing functionality.
🤖 Prompt for AI Agents
In Dockerfile lines 8 to 11, the sed command targets a file that may not exist,
causing build failures on some Debian images. To fix this, remove the sed
command or conditionally handle the file's absence, skip the apt-get upgrade to
reduce image size, add --no-install-recommends to apt-get install for a leaner
image, and combine all apt-get commands into a single RUN statement to reduce
layers and ensure cleanup runs unconditionally.
Hi,
When I ran the Docker file, I got issue unable to install packages within the container as by default debian using the http URL which runs on 80 port by default and system is keep ignoring the URL, so i modified the URL from http to https with sed command and afterwards it pulls the packages with secure 443 port due to https in URL.
Summary by CodeRabbit