我认为通常不允许普通用户通过运行chown没有sudo. 在 unix.stackexchange 上提出并回答了一个问题:为什么普通用户不能访问chown文件?。我明白了为什么要这样设计。
最近我开始玩rootless Podman。然后我了解到,例如,我可以运行
podman unshare chown -R 1111:1111 folder/
Run Code Online (Sandbox Code Playgroud)
将文件夹的所有权更改folder为另一个用户/组(在上面的示例中,默认101110:101110情况下位于主机上)。
从某种意义上说,它打破了前面提到的限制。为什么这是允许的?它会导致一些潜在的安全问题吗?/etc/subid(也许 root 用户在分配命名空间时应该小心?)
我只是一个业余爱好者,我在自己的笔记本电脑上运行所有内容。所以我不需要对此过于担心。不过,我想问这个问题只是出于好奇。
我有 Windows 10 专业版 1903(内部版本 18362.836)。Hyper-V 已启用。Docker Desktop 3.1.0 安装失败,出现以下错误。任何帮助将不胜感激。
Component CommunityInstaller.EnableFeaturesAction failed:
at CommunityInstaller.InstallWorkflow.<DoHandleD4WPackageAsync>d__29.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at CommunityInstaller.InstallWorkflow.<DoProcessAsync>d__23.MoveNext()
Run Code Online (Sandbox Code Playgroud) 我尝试使用 Dockerfile 和 SSH 密钥对从 GitLab 克隆一个测试项目:ssh-keygen -t rsa -P ""。私钥无密码,公钥发布在 GitLab 帐户上。
其他人可以快速测试这一点,只需在 GitLab 上开设一个帐户并发布您的 SSH 公钥,然后添加一个新的空项目进行克隆即可。
没有 Docker,使用ssh -i C:\path\to\my\private_key\id_rsa git@gitlab.com,它就可以工作。没有 Docker,克隆项目也可以工作。
我将私钥加载到 Dockerfile 中,最后将其删除。不重要,但对于所有在这里看到安全风险的人来说:我在使用后直接删除客户端和服务器上的密钥对。我只在克隆时尝试绕过用户帐户的密码条目,因为这在 Dockerfile 运行期间似乎不起作用,并且将是真正的安全风险,因为它可能会将密码留在日志中。
开始:转到 Dockerfile 目录,将私钥“id_rsa”粘贴到新的“.ssh”子文件夹中。然后:
docker build -t NEW_IMAGENAME . --build-arg ssh_prv_key="$(cat ./.ssh/id_rsa)"
Run Code Online (Sandbox Code Playgroud)
到目前为止的工作代码:
FROM vcatechnology/linux-mint:18.2
ARG ssh_prv_key
RUN apt-get update && \
apt upgrade -y && \
apt-get install -y git
RUN apt-get install -y openssh-client # openssh-server
RUN mkdir /root/.ssh/
RUN echo "Host *\n User git\n HostName …Run Code Online (Sandbox Code Playgroud) 我了解 docker-desktop 的 WSL2 后端通过创建 2 个发行版来工作:docker-desktop& docker-desktop-data。
我可以看到这些发行版的文件系统安装在我的 Ubuntu WSL2 发行版中:
grant@BeastMini-II:~$ ls -l /mnt/wsl
total 4
drwxr-xr-x 4 root root 100 Apr 1 09:12 docker-desktop
drwxr-xr-x 3 root root 60 Apr 1 09:12 docker-desktop-bind-mounts
drwxr-xr-x 4 root root 80 Apr 1 09:12 docker-desktop-data
-rw-r--r-- 1 root root 197 Apr 1 09:12 resolv.conf
Run Code Online (Sandbox Code Playgroud)
当我通过 Powershell 查看 docker-desktop-data 时,我可以看到文件系统中的各种文件:
PS C:\Users\grant> ls \\wsl$\docker-desktop-data
Directory: \\wsl$\docker-desktop-data
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 01/02/2023 18:36 …Run Code Online (Sandbox Code Playgroud) 我正在尝试只在 Docker 容器apt-get update上ubuntu:22.04。在我的本地计算机上,当我启动一个新的ubuntu:22.04docker 容器时run apt-get update,没有发生错误。然而,在我的詹金斯管道上,我得到了这个:
09:37:57 + apt-get update --allow-insecure-repositories
09:37:58 Get:1 http://archive.ubuntu.com/ubuntu jammy InRelease [270 kB]
09:37:58 Get:2 http://security.ubuntu.com/ubuntu jammy-security InRelease [110 kB]
09:37:58 Ign:2 http://security.ubuntu.com/ubuntu jammy-security InRelease
09:37:58 Get:3 http://security.ubuntu.com/ubuntu jammy-security/multiverse amd64 Packages [23.2 kB]
09:37:59 Get:4 http://archive.ubuntu.com/ubuntu jammy-updates InRelease [119 kB]
09:37:59 Ign:1 http://archive.ubuntu.com/ubuntu jammy InRelease
09:37:59 Get:5 http://security.ubuntu.com/ubuntu jammy-security/universe amd64 Packages [909 kB]
09:37:59 Ign:4 http://archive.ubuntu.com/ubuntu jammy-updates InRelease
09:37:59 Get:6 http://archive.ubuntu.com/ubuntu jammy-backports InRelease [108 kB]
09:37:59 …Run Code Online (Sandbox Code Playgroud) 使用 docker 1.9.0 版
我有一个提供 ubuntu 可信赖镜像 (trusty-mirror) 的 docker 容器。我正在尝试构建第二个容器并希望它从 trusty-mirror 更新和安装软件包。
我的第二个容器的 Dockerfile 有;
FROM ubuntu:14.04
RUN sed -i -e s#http://archive.ubuntu.com#${MIRROR}#g \
-e s#http://security.ubuntu.com#${MIRROR}#g \
/etc/apt/sources.list
RUN cat /etc/apt/sources.list
RUN apt-get update
RUN apt-get -y upgrade
RUN apt-get -y autoremove
Run Code Online (Sandbox Code Playgroud)
我使用--build-arg option将 MIRROR 信息传递给 docker build ,就像这样;
ip=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' trusty-mirror 2>/dev/null)
docker build --build-arg MIRROR=ftp://$ip
Run Code Online (Sandbox Code Playgroud)
当这个运行时;
+++ docker inspect --format '{{ .NetworkSettings.IPAddress }}' trusty-mirror
++ ip=172.17.0.2
++ docker build --build-arg MIRROR=ftp://172.17.0.2 . …Run Code Online (Sandbox Code Playgroud) 这是我的 Dockerfile:
FROM php:7.0-apache
Run Code Online (Sandbox Code Playgroud)
我docker exec -it <hash> bash从 CLI 执行,然后执行mysql并收到bash: mysql: command not found错误。
我有apt-get install mysql,但找不到包裹。当我尝试安装mysql-client和mysql-server.
如果我想在 Ubuntumysql-client中安装 mysql就可以了。
我想从远程机器运行一个容器化的 GUI 应用程序。
我不想通过向容器添加 ssh 主机来解决这个问题,因为
我已经可以在主机上成功运行 GUI 应用程序,但不能从容器内运行。这些是我迄今为止采取的步骤:
xauth + (不是长期的,但有助于消除可能的问题)docker-user主机上的 uid 501000 ==docker-user容器中的 uid 1000 通过命名空间功能.Xauthority文件复制到docker-user主文件夹xauth并且为了测试目的,xtermdocker-user使用适当的 uid/gid创建DISPLAY转发的环境变量/home/docker-user/:/home/docker-user/:ro提供.Xauthority的cookie/tmp/.X11-unix:/tmp/.X11-unix:ro提供X11插槽接入su - docker-user -c "export DISPLAY=$DISPLAY && xterm"
su 曾经作为 docker-userDISPLAY转发到su上下文中不幸的是,这还不够。虽然主机操作系统上的 xterm 连接到我的本地 X 服务器没有问题,但容器中的 xterm 显示Xt error: Can't open display: …
我有一个用例,我创建了一个 Docker macvlan 网络(默认桥接模式)并将这个网络连接到一个正在运行的 Docker 容器(例如 C1)。所以容器会有一个新的 macvlan 接口(例如 eth1)。
docker network create -d macvlan --subnet=172.16.16.0/24 --gateway=172.16.16.1 -o parent=ens224 macvlan-ens224
docker network connect macvlan-ens224 C1
Run Code Online (Sandbox Code Playgroud)
在容器 C1 中,我使用 macvlan (eth1) 接口和分配的 IP 创建了一个 macvtap 接口。
ip link add link eth1 name mymacvtap0 type macvtap mode private
ip addr add 172.17.17.2/24 dev mymacvtap0
ip link set up dev mymacvtap0
Run Code Online (Sandbox Code Playgroud)
现在,当我从容器内部 ping 子网 172.17.17.2/24 的某个 IP 时,使用容器 macvtap 接口的源 MAC 地址广播容器 ARP 请求。目标 IP 发回 ARP 回复。ARP 回复到达物理接口 ens224(从 tcpdump 中看到)。但是 Reply …
Kubernetes 新手我很难登录到 kubernetes 仪表板。
我跟着:https : //github.com/kubernetes/dashboard/wiki/Creating-sample-user
和
kubectl get clusterrolebinding admin-user -n kube-system -o yaml
显示:
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"rbac.authorization.k8s.io/v1","kind":"ClusterRoleBinding","metadata":{"annotations":{},"name":"admin-user"},"roleRef":{"apiGroup":"rbac.authorization.k8s.io","kind":"ClusterRole","name":"cluster-admin"},"subjects":[{"kind":"ServiceAccount","name":"admin-user","namespace":"kube-system"}]}
creationTimestamp: "2019-01-15T15:48:33Z"
name: admin-user
resourceVersion: "2096"
selfLink: /apis/rbac.authorization.k8s.io/v1/clusterrolebindings/admin-user
uid: 0361cb77-18dd-11e9-b02d-bc305b9f3aeb
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: admin-user
namespace: kube-system
Run Code Online (Sandbox Code Playgroud)
现在kubectl -n kube-system get secret | egrep admin没有显示任何内容(与上面页面的声明相矛盾......)我错过了什么?
蒂亚!
docker ×10
linux ×2
ubuntu ×2
windows ×2
alpine-linux ×1
apt-get ×1
build ×1
chown ×1
clone ×1
container ×1
git ×1
jenkins ×1
kubernetes ×1
mysql ×1
networking ×1
permissions ×1
ssh ×1
ssh-keys ×1
windows-10 ×1
wsl2 ×1