Commit c5e31fe3 authored by Elijah Grubb's avatar Elijah Grubb

Adding default USER, HOME, and PATH to docker imgs

parent f0b36cb7
......@@ -5001,8 +5001,32 @@ sub emulabizeImage($;$$$$$$$$$)
print $runitfile "\n";
print $runitfile "# This is an automatically generated runit file based on the docker image's entrypoint and cmd\n\n";
my $dockeruser;
my $dockerenvironmentvars;
$dockeruser = $iattrs{DOCKER_USER};
# we need to make sure user, home, and path are properly
# initialized so anything happening inside the startup command
# doesn't unexpectedly fail
if ($dockeruser ne "") {
print $runitfile "export USER=";
print $runitfile $dockeruser;
print $runitfile "\n";
print $runitfile "export HOME=/home/";
print $runitfile $dockeruser;
print $runitfile "\n";
else {
print $runitfile "export USER=root\n";
print $runitfile "export HOME=/root\n";
print $runitfile "export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin";
print $runitfile ':$PATH';
print $runitfile "\n\n";
# let's add in all the environment variables in the Dockerfile
if (exists($iattrs{DOCKER_ENV})) {
$dockerenvironmentvars = $iattrs{DOCKER_ENV};
foreach my $elem (@$dockerenvironmentvars) {
......@@ -5030,7 +5054,6 @@ sub emulabizeImage($;$$$$$$$$$)
my $dockerentrypoint;
my $dockercmd;
my $dockeruser;
my $dockerworkingdir;
if ($iattrs{DOCKER_WORKINGDIR} ne "") {
......@@ -5038,15 +5061,13 @@ sub emulabizeImage($;$$$$$$$$$)
print $runitfile "cd ";
print $runitfile $dockerworkingdir;
print $runitfile "\n\n";
$dockeruser = $iattrs{DOCKER_USER};
print $runitfile "if [ ! -f /etc/emulab/docker/dockercmd ]; then\n";
print $runitfile "exec ";
# if the user for the container is specified otherwise
# if the user for the container is specified
# need to run it as that user
if ($dockeruser ne "") {
print $runitfile "sudo -u ";
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment