uber-archive / makisu

Fast and flexible Docker image building tool, works in unprivileged containerized environments like Mesos and Kubernetes.
Apache License 2.0
2.41k stars 153 forks source link

HOME env instantiated incorrectly when USER is configured as ID in Dockerfile #364

Open Pectojin opened 3 years ago

Pectojin commented 3 years ago

Describe the bug We have some constraints on our k8s environment, which requires us to declare our user by ID instead of name. This normally works fine, when buidling with Docker or Kaniko, but I've observed that Makisu doesn't get this quite right. The container starts as the intended user but the HOME env variable is wrong, breaking things like simply compiling a go binary.

To Reproduce Using ubuntu as a base, then creating a user on ID 1000, and setting USER 1000:

FROM ubuntu:latest

RUN adduser builder --uid 1000 --disabled-password --home=/home/builder --gecos ""
USER 1000

RUN whoami
RUN env

Which, when built, will print:

% whoami
builder
% env
HOME=/home/1000
...

Expected behavior When building the above dockerfile I expect:

% whoami
builder
% env
HOME=/home/builder
...

Which is what I get using Kaniko or Docker to build.

Screenshots image

Environments This happens both when Makisu runs in our containerd k8s cluster and when I run Makisu locally in Docker.