windows docker 执行apt-get 权限问题

今天在windows下安装的docker 部署的容器执行apt-get遇到权限问题

bash 复制代码
PS C:\Users\xiaok> docker exec -it jenkins sh
$ apt-get update
Reading package lists... Done
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
$ sudo apt-get update
sh: 2: sudo: not found
$ su apt-get update
su: user apt-get does not exist or the user entry does not contain all the required fields
$ apk add --no-cache sudo
sh: 4: apk: not found

换一个命令执行

bash 复制代码
   docker exec -u 0 -it <jenkins_container_id> /bin/bash

由于我的容器是jenkins 所以我的执行命令是

bash 复制代码
   docker exec -u 0 -it jenkins /bin/bash
bash 复制代码
PS C:\Users\xiaok> docker exec -u 0 -it jenkins /bin/bash
root@3be2defd39e0:/# 

这个时候再去执行apt-get update就可以了

相关推荐
容器魔方2 天前
Bloomberg 正式加入 Karmada 用户组!
云原生·容器·云计算
muyun28002 天前
Docker 下部署 Elasticsearch 8 并集成 Kibana 和 IK 分词器
elasticsearch·docker·容器
Nazi62 天前
k8s的dashboard
云原生·容器·kubernetes
路由侠内网穿透2 天前
本地部署 GPS 跟踪系统 Traccar 并实现外部访问
运维·服务器·网络·windows·tcp/ip
傻傻虎虎2 天前
【Docker】常用帮忙、镜像、容器、其他命令合集(2)
运维·docker·容器
是小崔啊2 天前
叩丁狼K8s - 概念篇
云原生·容器·kubernetes
研华嵌入式2 天前
如何在高通跃龙QCS6490 Arm架构上使用Windows 11 IoT企业版?
arm开发·windows·嵌入式硬件
2401_897930062 天前
使用Docker轻松部署Neo4j图数据库
数据库·docker·neo4j
LeeZhao@3 天前
【AI推理部署】Docker篇04—Docker自动构建镜像
人工智能·docker·容器
程思扬3 天前
利用JSONCrack与cpolar提升数据可视化及跨团队协作效率
网络·人工智能·经验分享·docker·信息可视化·容器·架构