Docker 中使用超级用户

在docker中安装keytool产生的问题:

bash 复制代码
sudo apt-get install openjdk-8-jre-headless
bash: sudo: command not found
elasticsearch@d989639e3cb4:~/config/certs$ apt-get install openjdk-8-jre-headless
E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?
elasticsearch@d989639e3cb4:~/config/certs$ sudo apt-get install openjdk-8-jre-headless
bash: sudo: command not found
elasticsearch@d989639e3cb4:~/config/certs$ su
Password: 
su: Authentication failure
elasticsearch@d989639e3cb4:~/config/certs$ su
Password: 
su: Authentication failure
elasticsearch@d989639e3cb4:~/config/certs$ apt-get update && apt-get install -y openjdk-8-jre-headless
Reading package lists... Done
E: List directory /var/lib/apt/lists/partial is missing. - Acquire (13: Permission denied)
elasticsearch@d989639e3cb4:~/config/certs$ exit

docker exec -u 0 -it <容器名称或ID> /bin/bash

例如:

docker exec -u 0 -it d989639e3cb4 /bin/bash

然后直接使用apt,不需要加sudo

apt-get update && apt-get install -y openjdk-8-jre-headless

相关推荐
hxdcxy1 小时前
中间件部署
运维·服务器
李少兄4 小时前
CentOS系统下前后端项目部署攻略
linux·运维·centos
咚咚?5 小时前
基于gitlab 构建CICD发布到K8S 平台
容器·kubernetes·gitlab
Two_brushes.6 小时前
【Linux】线程机制深度实践:创建、等待、互斥与同步
linux·运维·服务器·多线程
尘土哥7 小时前
Docker 快速上手
docker·容器·eureka
设计师小聂!8 小时前
Linux系统中部署Redis详解
linux·运维·数据库·redis
广州山泉婚姻9 小时前
Docker从环境配置到应用上云的极简路径
docker
努力做小白10 小时前
Linux驱动11 --- buildroot&杂项驱动开发方法
linux·运维·驱动开发·单片机·嵌入式硬件
Sally璐璐10 小时前
Memcache核心技术解析与实战应用
运维·wpf·memcached
哈哈浩丶10 小时前
Linux驱动开发1:设备驱动模块加载与卸载
linux·运维·驱动开发