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

相关推荐
PyAIGCMaster14 分钟前
ubuntu装P104驱动
linux·运维·ubuntu
奈何不吃鱼14 分钟前
【Linux】ubuntu依赖安装的各种问题汇总
linux·运维·服务器
aherhuo20 分钟前
kubevirt网络
linux·云原生·容器·kubernetes
zzzhpzhpzzz28 分钟前
Ubuntu如何查看硬件型号
linux·运维·ubuntu
蜜獾云30 分钟前
linux firewalld 命令详解
linux·运维·服务器·网络·windows·网络安全·firewalld
陌北v132 分钟前
Docker Compose 配置指南
运维·docker·容器·docker-compose
只会copy的搬运工1 小时前
Jenkins 持续集成部署——Jenkins实战与运维(1)
运维·ci/cd·jenkins
catoop1 小时前
K8s 无头服务(Headless Service)
云原生·容器·kubernetes
娶不到胡一菲的汪大东1 小时前
Ubuntu概述
linux·运维·ubuntu
阿里嘎多学长1 小时前
docker怎么部署高斯数据库
运维·数据库·docker·容器