Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/clojure/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法生成docker映像,";必须是根用户“;_Docker_Dockerfile_Expect - Fatal编程技术网

无法生成docker映像,";必须是根用户“;

无法生成docker映像,";必须是根用户“;,docker,dockerfile,expect,Docker,Dockerfile,Expect,我通过在容器内安装应用程序(安装时应为root用户)来创建Docker映像 # 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

我通过在容器内安装应用程序(安装时应为root用户)来创建Docker映像

# 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
docker映像的生成过程:

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
要确认容器以root用户身份运行,请执行以下操作:

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
无法找出应用程序安装失败的原因,即使它以root用户身份运行

编辑:添加login.exp脚本:此脚本非常基本,可以完成我的功能

#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

root的容器版本和您在主机上知道的root不一定是同一件事。最大的区别是docker从根用户中删除了各种功能,以防止它们脱离容器,因此用户无法访问物理硬件设备,在这些设备中,他们可以直接在容器中装入硬盘驱动器,或者调整cgroup设置以跳出命名空间

从您正在运行的文件的名称来看,您似乎正在尝试安装需要访问硬件的KVM。我不认为这将是一个容器的最佳使用案例,该容器设计用于可移植性和与硬件隔离,而该应用程序的设计可能将硬件特定配置和访问作为关键要求


虽然
docker build
不允许硬件访问,但您可以使用
docker run--privileged
手动执行安装,然后
docker commit
将该容器保存到映像中。这通常是您构建映像的最后一种方法,但在这种情况下,如果可能的话,这可能是唯一的方法。

login.exp中有什么内容?Expect通常会监视模式的输出,以检测它正在查找的内容。如果没有看到login.exp,我猜它是在寻找一个shell提示模式,它认为它的意思是“root用户”,而没有看到那个特定的模式。