From f1d398ba8182f78c4caf21e9fc47e11d3cb5a0f6 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Sun, 10 Oct 2021 14:13:52 -0400 Subject: [PATCH] Add docker_user and password args to Dockerfile Symlinking /etc/passwd files leads to invalid cross-device link errors when running apt commands. Internally, apt uses dpkg, which adds a user "irc" when performing apt installs/upgrades. This subprocess leads to the error. The solution implemented here creates a user with the same name and id as the current user. This gives both users the the same file permissions, without having to symlink /etc/passwd. --- Dockerfile | 6 ++++++ build.sh | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 03854be..5e0efa4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -231,3 +231,9 @@ RUN \ && DEBIAN_FRONTEND=noninteractive apt-get autoremove -y ######################## + +ARG docker_user +ARG docker_user_id +ARG docker_password + +RUN useradd -u $docker_user_id -m $docker_user && echo "${docker_user}:${docker_password}" | chpasswd && adduser $docker_user sudo diff --git a/build.sh b/build.sh index a99d660..d565420 100755 --- a/build.sh +++ b/build.sh @@ -1 +1,8 @@ -docker build -t bluetradingsystems/linux_docker . +#!/usr/bin/env bash + +docker build \ + --build-arg docker_user=$USER \ + --build-arg docker_user_id=$(id -u) \ + --build-arg docker_password=$USER \ + -t spark-crypto_18.04 \ + .