When we run as root on the host and want to allow the builder to do the same, e.g. to access root-owned volumes, accept USER_ID=0 to express this. This allows to tell the user to call "docker run -e USER_ID=$(id -u)", and it will always reflect the calling context's permissions into the container. Reported-by: Jan Christian Grünhage <jan.christian@gruenhage.xyz> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
		
			
				
	
	
		
			37 lines
		
	
	
		
			759 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			37 lines
		
	
	
		
			759 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
#!/bin/bash
 | 
						|
 | 
						|
if mount | grep -q "on / type aufs"; then
 | 
						|
    cat <<EOF >&2
 | 
						|
WARNING: Generation of wic images will fail!
 | 
						|
 | 
						|
Your docker host setup uses broken aufs as storage driver. Adjust the docker
 | 
						|
configuration to use a driver (overlay, overlay2, devicemapper). You may also
 | 
						|
need to update the host distribution (e.g. Debian Jessie -> Stretch).
 | 
						|
 | 
						|
EOF
 | 
						|
fi
 | 
						|
 | 
						|
USER_ID=${USER_ID:-30000}
 | 
						|
 | 
						|
if [ $USER_ID == 0 ]; then
 | 
						|
	# We shall run everything as root
 | 
						|
	mkdir /builder
 | 
						|
 | 
						|
	cd /builder
 | 
						|
	if [ -n "$1" ]; then
 | 
						|
		exec "$@"
 | 
						|
	else
 | 
						|
		exec bash
 | 
						|
	fi
 | 
						|
else
 | 
						|
	# Create a non-root user that will perform the actual build
 | 
						|
	useradd --uid $USER_ID --create-home --home-dir /builder builder
 | 
						|
 | 
						|
	cd /builder
 | 
						|
	if [ -n "$1" ]; then
 | 
						|
		exec gosu builder "$@"
 | 
						|
	else
 | 
						|
		exec gosu builder bash
 | 
						|
	fi
 | 
						|
fi
 |