2

I installed libpcap in my container using below docker file using docker file below. How do I make sure it was installed and working as expected?

I tried below with the hope to see libpcap

D:\work >docker exec -u 0 -it containerId sh

/app # cd /etc/apk

/etc/apk # cat repositories

http://dl-cdn.alpinelinux.org/alpine/v3.8/main

http://dl-cdn.alpinelinux.org/alpine/v3.8/community

/etc/apk # 

Below is my docker file

FROM mcr.microsoft.com/dotnet/core/sdk:2.2-alpine AS build

# Install packages
RUN apk update
RUN apk -U --no-cache add libpcap

Running the apk info command has below output

WARNING: Ignoring APKINDEX.adfa7ceb.tar.gz: No such file or directory

WARNING: Ignoring APKINDEX.efaa1f73.tar.gz: No such file or directory

musl

busybox

alpine-baselayout

alpine-keys

libressl2.7-libcrypto

libressl2.7-libssl

libressl2.7-libtls

ssl_client

zlib

apk-tools

scanelf

musl-utils

libc-utils

ca-certificates

krb5-conf

libcom_err

keyutils-libs

libverto

krb5-libs

libgcc

libintl

libcrypto1.0

libssl1.0

libstdc++

userspace-rcu

lttng-ust

tzdata

user3023949
  • 121
  • 2
  • 8
  • 2
    Possible duplicate of [How to check whether python package is installed or not in Docker?](https://stackoverflow.com/questions/27520619/how-to-check-whether-python-package-is-installed-or-not-in-docker) – Kelvin Lai Jun 17 '19 at 02:08

1 Answers1

3

Run docker exec command and try this

$ apk info

This will list all the installed packages in alpine.

I can see libcap in the output.

If you still can't see the package. Make sure you have run apk update before installing libcap

mchawre
  • 10,744
  • 4
  • 35
  • 57
  • Humm...what's wrong I don't see libpcap in the list of my container. – user3023949 Jun 17 '19 at 17:03
  • I used the exact docker image which you trying `mcr.microsoft.com/dotnet/core/sdk:2.2-alpine` and I can see libcap in it. – mchawre Jun 17 '19 at 17:20
  • Try `docker run -itd mcr.microsoft.com/dotnet/core/sdk:2.2-alpine sh` and then do `doxker exec -it containerid sh` and run `apk add libcap` and check if it shows libcap package. – mchawre Jun 17 '19 at 17:22
  • I updated my answer please check apk update might be missing in your case. – mchawre Jun 17 '19 at 17:25
  • I see libpcap in the list your commands are run, but not using my docker file (I posted my docker file) – user3023949 Jun 17 '19 at 17:36
  • Add `RUN app update` in your dockerfile and try to build and run the image – mchawre Jun 17 '19 at 17:38
  • You mean RUN apk update? I did, after that libpcap wasn't displayed with apk info command – user3023949 Jun 17 '19 at 17:47
  • Yes, I did put apk update before add after which built the container still I don't see libpcap in the apk info list. – user3023949 Jun 17 '19 at 17:57
  • I suspect that `--no-cache` option in apk add command might causing it to not get it listed in apk info command. Can you try to remove that no-cache option and try again. – mchawre Jun 17 '19 at 18:02
  • Moving RUN command to the end of docker file (before endpoint) worked. – user3023949 Jun 17 '19 at 19:09
  • Great! If my answer helped you, then please upvote and accept my answer. :) – mchawre Jun 18 '19 at 04:23