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

相关推荐
zdd567893 小时前
行存表与列存表简述
运维·postgresql
福尔摩斯张3 小时前
Linux的pthread_self函数详解:多线程编程中的身份标识器(超详细)
linux·运维·服务器·网络·网络协议·tcp/ip·php
2401_832298103 小时前
一云多芯时代:云服务器如何打破芯片架构壁垒
运维·服务器·架构
m0_488777653 小时前
运用Docker-compose编排部署设备管理平台(包含nginx的https访问)
docker·容器·docker-compose·服务统一管理
汪碧康4 小时前
二进制kubenetes-1.34.2安装包快速部署k8s集群
云原生·容器·kubernetes·k8s·etcd·xkube
Web极客码4 小时前
如何在 Linux 中终止一个进程?
linux·运维·服务器
我爱学习好爱好爱4 小时前
Docker Compose部署SpringBoot2+Vue3+redis项目(Rockylinux9.6)
redis·docker·容器
一枚正在学习的小白4 小时前
prometheus监控对外服务
运维·prometheus
tzhou644524 小时前
Docker Compose 编排与 Harbor 私有仓库
运维·docker·容器
Clarence Liu4 小时前
虚拟机与容器的差异与取舍
linux·后端·容器