Unable to build docker image, “must be a root user”

I am creating a Docker image by installing an application(should be a root user for installing) inside the container.

# cat Dockerfile 
FROM ubuntu:16.04
COPY $pwd/intel_virtual_gateway_console64_1_9_0.tar /root/
COPY $pwd/login.exp /root/
WORKDIR /root/
RUN tar -xvf intel_virtual_gateway_console64_1_9_0.tar 
RUN apt-get update && apt-get install -y expect \
                      expect-dev \
                      libxml2-utils
RUN whoami
RUN expect login.exp

Build process for docker image:

  • Can Docker help build executable that work in different platform
  • Does data needs to have a specific format to upload it in Docker?
  • CHMOD in dockerfile for python
  • How to generate a certificate for AWS EC2 instance part of AWS ECS ( Docker)
  • Upgrade jdk version of Tomcat docker container to 1.8
  • Docker LXC driver vs libcontainer
  • root@labadmin-VirtualBox:~/RAGHU/krishna# docker build -t release:4.0 .
    Sending build context to Docker daemon  633.5MB
    Step 1/8 : FROM ubuntu:16.04
     ---> 6a2f32de169d
    Step 2/8 : COPY $pwd/intel_virtual_gateway_console64_1_9_0.tar /root/
     ---> Using cache
     ---> 36e9ea407082
    Step 3/8 : COPY $pwd/login.exp /root/
     ---> Using cache
     ---> 0fad538973d4
    Step 4/8 : WORKDIR /root/
     ---> Using cache
     ---> f5d7f36bc37f
    Step 5/8 : RUN tar -xvf intel_virtual_gateway_console64_1_9_0.tar
     ---> Using cache
     ---> 6cab428f1bc2
    Step 6/8 : RUN apt-get update && apt-get install -y expect                       expect-dev                       libxml2-utils
     ---> Using cache
     ---> 5bb1ee67332f
    

    To confirm that the container is running as root user:

    Step 7/8 : RUN whoami
     ---> Running in 112b87d77a08
    root
     ---> 0c7eb38cc06b
    Removing intermediate container 112b87d77a08
    Step 8/8 : RUN expect login.exp
     ---> Running in 5f186baf2f8d
    spawn ./virtualgatewayconsole_package/virtual_gateway_console_intel64
    Install Error
    --------------------------------------------------------------------------------
    To install the application, you must be a root user.
    --------------------------------------------------------------------------------
    Type any key to exit: ^C
    

    Unable to find out why the application installation has failed even though it is run as root user.

    EDIT : ADDING login.exp script: This script is so basic to get my functionality done.

    #cat login.exp 
    #!/usr/bin/expect -f
    
    if 0 {
         *************************READ THIS BEFORE START*********************
         User password must consist of at least 3 of the following categories: 
         uppercase, lowercase, numeric, and non-alphanumeric. In case of violation
         of this rule the Installation will fail!
         ********************************************************************
         }
    set passwd "ISHAAN@p2017"
    set username "raghu"
    
    spawn ./virtualgatewayconsole_package/virtual_gateway_console_intel64
    expect "Press Enter key to continue or q to quit:" 
    send "\n" 
    
    expect "Press ENTER for more, or q when done"  
    send "q" 
    
    sleep 5
    #expect "conditions of this license agreement?"
    expect "*(accept/decline): "  
    send "accept\n" 
    
    #Product installation
    expect "*Please type a selection \[1\]:" 
    send "\n" 
    
    expect "*Please type a selection (Press Enter to next):" 
    send "\n" 
    
    sleep 2
    #Configure TLS settings
    expect "*Enter TLS keystore password (only numbers, letters and !@#$%^*()_+{}|.:?=-):"
    send $passwd
    send "\n"
    
    expect "*Retype TLS keystore password:"
    send $passwd
    send "\n"
    
    sleep 2
    expect "Please type a selection (Press Enter to next):"
    send "\n"
    
    #Configure host
    expect "Please type a selection (Press Enter to next):"
    send "\n"
    
    expect "Please type a selection (Press Enter to next):"
    send "\n"
    
    #Configure user for logging on the management console
    expect "Please type a selection (Press Enter to next):"
    send "\n"
    
    sleep 2
    expect "Enter user password (only numbers, letters, spaces and !@#$%^*()_+{}|.:?=-):"
    send $passwd
    send "\n"
    
    expect "Retype user password:"
    send $passwd
    send "\n"
    
    expect "Please type a selection (Press Enter to next):"
    send "\n"
    
    sleep 2
    #Configure PostgreSQL service
    expect "Please type a selection (Press Enter to next):"
    send "\n"
    
    expect "Enter PostgreSQL user password (only numbers, letters and !@#$%^*()_+{}|.:?=-):"
    send $passwd
    send "\n"
    
    expect "Retype PostgreSQL user password:"
    send $passwd
    send "\n"
    
    expect "Please type a selection (Press Enter to next):" 
    send "\n"
    
    sleep 60
    #Create Keystore
    expect "What is your first and last name?"
    send $username
    send "\n"
    
    expect "What is the name of your organizational unit?"
    send "radisys"
    send "\n"
    
    expect "What is the name of your organization?"
    send "radisys"
    send "\n"
    
    sleep 2
    expect "What is the name of your City or Locality?"
    send "banglore"
    send "\n"
    
    expect "What is the name of your State or Province?"
    send "karnataka"
    send "\n"
    
    expect "What is the two-letter country code for this unit?"
    send "IND"
    send "\n"
    
    sleep 2
    expect "Is CN=raghu, OU=radisys, O=radisys, L=banglore, ST=karnataka, C=IND correct?"
    send "yes"
    send "\n"
    
    sleep 2
    expect "Please type a selection \[q\]:"
    send "q"
    
    expect eof
    

  • Pika to RabbitMQ connection failure using Raspberry PI and Docker container
  • mounting local home directory in Rstudio docker?
  • My app can't create log files when it starts up inside Docker
  • How can we use shared Dockerfile's which reside in different directories than the “current build context path”?
  • How to create docker image for local application taking file and value parameters
  • Docker Compose Dev and Production Environments Best Workflow
  • One Solution collect form web for “Unable to build docker image, “must be a root user””

    The container version of root and the root you know on the host are not necessarily the same thing. The biggest difference is that docker removes various capabilities from the root user to prevent them from breaking out of the container, so the user doesn’t have access to physical hardware devices where they could mount the harddrive directly inside the container, or adjust the cgroup settings to escape the namespace.

    From the name of the file you’re running, it looks like you’re trying to install a KVM which will need to access the hardware. I don’t think this is going to be the best use case for a container which is designed for portability and isolation from the hardware while this app is likely designed with hardware specific configuration and access as a key requirement.

    While docker build doesn’t allow hardware access, you could potentially use docker run --privileged to perform the install manually and then docker commit to save that container to an image. This is normally the last way you would want to build an image, but in this case, it may be the only way, assuming it’s possible at all.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.