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

相关推荐
johnny2335 小时前
运维管理面板:AcePanel、OpenOcta、DeepSentry
运维
青梅橘子皮6 小时前
Linux---基本指令
linux·运维·服务器
REDcker6 小时前
Linux信号机制详解 POSIX语义与内核要点 sigaction与备用栈实践
linux·运维·php
绘梨衣5477 小时前
Docker+FastAPI+MySQL 项目部署报错汇总
mysql·docker·fastapi
cui_ruicheng7 小时前
Linux进程间通信(三):System V IPC与共享内存
linux·运维·服务器
ACP广源盛139246256739 小时前
IX8024与科学大模型的碰撞@ACP#筑牢科研 AI 算力高速枢纽分享
运维·服务器·网络·数据库·人工智能·嵌入式硬件·电脑
百年੭ ᐕ)੭*⁾⁾10 小时前
docker使用neo4j
docker·容器·neo4j
峥无10 小时前
Linux系统编程基石:静态库·动态库·ELF文件·进程地址空间全景图
linux·运维·服务器
码云数智-大飞10 小时前
本地部署大模型:隐私安全与多元优势一站式解读
运维·网络·人工智能
Harvy_没救了11 小时前
【网络部署】 Win11 + VMware CentOS8 + Nginx 文件共享服务 Wiki
运维·网络·nginx