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

相关推荐
江湖有缘24 分钟前
Linux系统之rm命令的基本使用
linux·运维·服务器
曹天骄1 小时前
安装 Calico 的两种主流方式对比
容器·kubernetes
FOREVERHOPE_WBZ2 小时前
CentOS 中下载rpm包并安装
linux·运维·centos
kfhj2 小时前
DevOps与Docker的关系
运维·docker·容器·devops
dessler2 小时前
Kubernetes(k8s)-备份&Etcd介绍
linux·运维·kubernetes
晓风残月淡2 小时前
持续集成与Jenkins安装使用教程
运维·ci/cd·jenkins
菠萝蚊鸭2 小时前
openEuler-22.03-LTS-SP3 编译安装 Greenplum-db 6.20.0
运维·openeuler·greenplum-db
jz_ddk3 小时前
[实战] linux驱动框架与驱动开发实战
linux·运维·c语言·驱动开发·嵌入式硬件
企鹅侠客3 小时前
Prometheus告警从触发到收到通知延迟在哪?
运维·prometheus·监控
Ac157ol3 小时前
创建两个进程
linux·运维·网络