Quantcast
Channel: Active questions tagged dockerfile - DevOps Stack Exchange
Viewing all articles
Browse latest Browse all 136

Run Docker container with user who started it

$
0
0

I have two users on host machine usera, userb. I have added these users to the Dockerfile as below.

FROM ubuntu:latestENV DEBIAN_FRONTEND=noninteractive \    TERM=xtermRUN groupadd -g 1111 groupname && \    useradd -u 12345 -g 1111 -m -s /bin/bash usera && \    useradd -u 23456 -g 1111 -m -s /bin/bash userbRUN apt-get update ; \    apt-get upgrade ; \    apt-get install -y git ; \    apt-get install -y vim ; \    apt-get install -y curl ; \    apt-get clean ;USER useraWORKDIR /home/usera

Based on last two lines, when I give usera, then default user in container is usera. If I change it to userb, then default user in container is userb.

Is there any option to default to user (and their respective directory) who started the container? If usera runs the container, then the default user in container should be usera and directory should be /home/usera. If userb starts the container, then userb should be default user and directory should be /home/userb.


Viewing all articles
Browse latest Browse all 136

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>