docker-library / repo-info

Extended information (especially license and layer details) about the published Official Images
Apache License 2.0
554 stars 340 forks source link

how do you install files inside debian:buster-slim? #55

Closed decentration closed 2 years ago

decentration commented 2 years ago

In order to run my docker successfully i need to install update-ca-certificates, i have entered my image docker run -it --entrypoint bash <image-name-or-id> but if i try apt-get or apt-install i am getting command not found.

How can i install files in a debian:buster-slim?

wglambert commented 2 years ago

You want to use either apt-get update or apt update to first populate the list of package repositories (by default it's not populated to save space) then you can apt install ca-certificates

https://debian-handbook.info/browse/stable/sect.apt-get.html

apt-get is the first front end — command-line based — which was developed within the project. apt is a second command-line based front end provided by APT which overcomes some design mistakes of apt-get.

In the future questions like this should be asked over at the Docker Community Forums, Docker Community Slack, or Stack Overflow. Since these repos aren't really a user-help forum

decentration commented 2 years ago

@wglambert neither apt-get update or apt update works... bash: apt: command not found.

wglambert commented 2 years ago

I'm not able to reproduce

$ docker run -it --rm debian:buster-slim bash
Unable to find image 'debian:buster-slim' locally
buster-slim: Pulling from library/debian
ffbb094f4f9e: Pull complete
Digest: sha256:c72b2ae10bbe698b3279dcc63def01660a4431072e8d71b00f378b37b3eeda30
Status: Downloaded newer image for debian:buster-slim
root@8cc6c81db12d:/# apt update && apt install -y ca-certificates
Get:1 http://deb.debian.org/debian buster InRelease [122 kB]
Get:2 http://security.debian.org/debian-security buster/updates InRelease [65.4 kB]
Get:3 http://deb.debian.org/debian buster-updates InRelease [51.9 kB]
Get:4 http://security.debian.org/debian-security buster/updates/main amd64 Packages [309 kB]
Get:5 http://deb.debian.org/debian buster/main amd64 Packages [7906 kB]
Get:6 http://deb.debian.org/debian buster-updates/main amd64 Packages [15.2 kB]
Fetched 8470 kB in 2s (4771 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  libssl1.1 openssl
The following NEW packages will be installed:
  ca-certificates libssl1.1 openssl
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 2549 kB of archives.
After this operation, 6084 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian buster/main amd64 libssl1.1 amd64 1.1.1d-0+deb10u7 [1539 kB]
Get:2 http://deb.debian.org/debian buster/main amd64 openssl amd64 1.1.1d-0+deb10u7 [845 kB]
Get:3 http://deb.debian.org/debian buster/main amd64 ca-certificates all 20200601~deb10u2 [166 kB]
Fetched 2549 kB in 0s (59.1 MB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libssl1.1:amd64.
(Reading database ... 6460 files and directories currently installed.)
Preparing to unpack .../libssl1.1_1.1.1d-0+deb10u7_amd64.deb ...
Unpacking libssl1.1:amd64 (1.1.1d-0+deb10u7) ...
Selecting previously unselected package openssl.
Preparing to unpack .../openssl_1.1.1d-0+deb10u7_amd64.deb ...
Unpacking openssl (1.1.1d-0+deb10u7) ...
Selecting previously unselected package ca-certificates.
Preparing to unpack .../ca-certificates_20200601~deb10u2_all.deb ...
Unpacking ca-certificates (20200601~deb10u2) ...
Setting up libssl1.1:amd64 (1.1.1d-0+deb10u7) ...
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 78.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (Can't locate Term/ReadLine.pm in @INC (you may need to install the Term::ReadLine module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.28.1 /usr/local/share/perl/5.28.1 /usr/lib/x86_64-linux-gnu/perl5/5.28 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.28 /usr/share/perl/5.28 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at /usr/share/perl5/Debconf/FrontEnd/Readline.pm line 7.)
debconf: falling back to frontend: Teletype
Setting up openssl (1.1.1d-0+deb10u7) ...
Setting up ca-certificates (20200601~deb10u2) ...
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 78.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (Can't locate Term/ReadLine.pm in @INC (you may need to install the Term::ReadLine module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.28.1 /usr/local/share/perl/5.28.1 /usr/lib/x86_64-linux-gnu/perl5/5.28 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.28 /usr/share/perl/5.28 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at /usr/share/perl5/Debconf/FrontEnd/Readline.pm line 7.)
debconf: falling back to frontend: Teletype
Updating certificates in /etc/ssl/certs...
137 added, 0 removed; done.
Processing triggers for libc-bin (2.28-10) ...
Processing triggers for ca-certificates (20200601~deb10u2) ...
Updating certificates in /etc/ssl/certs...
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...
done.
decentration commented 2 years ago

i made the image with this Dockerfile:

COPY . /polkadot/
#RUN  fallocate -l 1G /swapfile

RUN rustup uninstall nightly
RUN rustup install nightly
RUN rustup update nightly
RUN rustup target add wasm32-unknown-unknown --toolchain nightly
RUN cargo clean
RUN cargo update
#RUN cargo +nightly-2021-11-01 check 
RUN cargo build --release

# ===== SECOND STAGE ======

FROM debian:buster-slim
LABEL description="This is the 2nd stage: a very small image where we copy the polkadot binary."
ARG PROFILE=release
COPY --from=builder /polkadot/target/$PROFILE/polkadot /usr/local/bin
COPY ./specs/ /specs/
RUN useradd -m -u 1000 -U -s /bin/sh -d /polkadot polkadot && \
    mkdir -p /polkadot/.local/share && \
    mkdir /data && \
    chown -R polkadot:polkadot /data && \
    ln -s /data /polkadot/.local/share/polkadot && \
    rm -rf /usr/bin /usr/sbin

USER polkadot
EXPOSE 30333-30343 9933-9960 8080 300
VOLUME ["/data"]

CMD ["/usr/local/bin/polkadot"]
yosifkit commented 2 years ago

You can't pass apt or any other binary directly to bash; you need to either interact with bash or give it a string via -c

$ # equivalent commands:
$ # docker run -it debian:buster-slim
$ # docker run -it --entrypoint bash debian:buster-slim
$ docker run -it debian:buster-slim bash
Unable to find image 'debian:buster-slim' locally
buster-slim: Pulling from library/debian
ffbb094f4f9e: Pull complete 
Digest: sha256:c72b2ae10bbe698b3279dcc63def01660a4431072e8d71b00f378b37b3eeda30
Status: Downloaded newer image for debian:buster-slim
root@5feacd5a3f64:/# # this is in a container
root@5feacd5a3f64:/# apt-get update
Get:1 http://deb.debian.org/debian buster InRelease [122 kB]
Get:2 http://deb.debian.org/debian buster-updates InRelease [51.9 kB]
Get:3 http://security.debian.org/debian-security buster/updates InRelease [65.4 kB]
Get:4 http://deb.debian.org/debian buster/main amd64 Packages [7906 kB]
Get:5 http://security.debian.org/debian-security buster/updates/main amd64 Packages [309 kB]
Get:6 http://deb.debian.org/debian buster-updates/main amd64 Packages [15.2 kB]
Fetched 8470 kB in 1s (6463 kB/s)                                                         
Reading package lists... Done
root@5feacd5a3f64:/# exit

$ # equivalent commands:
$ # docker run -it debian:buster-slim bash -c 'apt-get update'
$ docker run -it --entrypoint bash debian:buster-slim -c 'apt-get update'
Get:1 http://security.debian.org/debian-security buster/updates InRelease [65.4 kB]
Get:2 http://deb.debian.org/debian buster InRelease [122 kB]
Get:3 http://deb.debian.org/debian buster-updates InRelease [51.9 kB]
Get:4 http://security.debian.org/debian-security buster/updates/main amd64 Packages [309 kB]
Get:5 http://deb.debian.org/debian buster/main amd64 Packages [7906 kB]
Get:6 http://deb.debian.org/debian buster-updates/main amd64 Packages [15.2 kB]
Fetched 8470 kB in 1s (6843 kB/s)                           
Reading package lists... Done

You'll definitely want to look into Dockerfiles if you want to end with an image that contains the desired packages to reuse on other hosts. Containers are usually meant to be ephemeral.

decentration commented 2 years ago

thank you for that, very helpful. I will update Dockerfile interact in the way you mentioned.