"logname: no login name" inside Docker container when running dpkg -i

Viewed 641

I need to install an SDK package inside an Ubuntu 18.04 Docker container, but am constantly running into this problem:

theuser@e9fa4f39e0f0:/src/spinnaker$ sudo dpkg -i libspinnaker_2.2.0.48_arm64.deb
(Reading database ... 52013 files and directories currently installed.)
Preparing to unpack libspinnaker_2.2.0.48_arm64.deb ...
Unpacking libspinnaker (2.2.0.48) over (2.2.0.48) ...
logname: no login name
dpkg: warning: old libspinnaker package post-removal script subprocess returned error exit status 1
dpkg: trying script from the new package instead ...
logname: no login name
dpkg: error processing archive libspinnaker_2.2.0.48_arm64.deb (--install):
 new libspinnaker package post-removal script subprocess returned error exit status 1
logname: no login name
dpkg: error while cleaning up:
 new libspinnaker package post-removal script subprocess returned error exit status 1
Errors were encountered while processing:
 libspinnaker_2.2.0.48_arm64.deb

I've tried all manner of workarounds, setting USER, SUDO_USER, LOGNAME, running the container with the "-u" switch to my uid/gid and all get the same logname error. Is there a work around for this?

1 Answers

I had the same problem with the latest spinnaker api release.

The issue is that postinst call logname to find out where your home directory is, to install some config files. In the docker build context, there is no logged in user.

My egregious hack was to overwrite the logname executable with "echo root". e.g.:

# Install spinnaker sdk https://www.flir.com/support-center/iis/machine-vision/downloads/spinnaker-sdk-and-firmware-download/
COPY external/spinnaker/* spinnaker/
# Pre-answer the apt install prompts
COPY spinnaker.dat .
RUN cat spinnaker.dat >> /var/cache/debconf/config.dat
# Fake out logname (no login context in docker build)
RUN echo "echo root" > /usr/bin/logname
# Install other postinst dependencies
RUN DEBIAN_FRONTEND=noninteractive apt install -y iputils-ping wget
RUN DEBIAN_FRONTEND=noninteractive apt install -y --no-install-recommends ./spinnaker/lib*.deb && rm -rv spinnaker

The contents of spinnaker.dat (to avoid being prompted from the preinst script) are:

Name: libspinnaker/accepted-flir-eula
Template: libspinnaker/accepted-flir-eula
Value: true
Owners: libspinnaker
Flags: seen

Name: libspinnaker/error-flir-eula
Template: libspinnaker/error-flir-eula
Owners: libspinnaker

Name: libspinnaker/present-flir-eula
Template: libspinnaker/present-flir-eula
Value: 
Owners: libspinnaker
Flags: seen
Related