对于一个项目,我需要在运行ubuntu的docker容器中安装一个linux映像.我要挂载的图像是Raspbian.我需要访问图像的linux文件系统并添加一个文件.
我通过使用volume标志挂载文件夹来访问图像:
docker run -it -v /path/to/image/folder:/default ubuntu /bin/bash
随着fdisk -l raspbian.img我发现偏差:
Disk raspbian.img: 1.3 GiB, 1389363200 bytes, 2713600 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x5a7089a1
Device Boot Start End Sectors Size Id Type
raspbian.img1 8192 137215 129024 63M c W95 FAT32 (LBA)
raspbian.img2 137216 2713599 2576384 1.2G 83 Linux
Run Code Online (Sandbox Code Playgroud)
现在,当我尝试装载图像时, …
我使用 docker swarm 模式运行 docker swarm。假设我有 4 个节点,1 个管理器,3 个工作器。主机名是:
我以模式启动服务global,因此每个节点都运行该服务一次。假设该命令如下所示:
docker service create --name myservice --mode global --network mynetwork ubuntu wait 3600
Run Code Online (Sandbox Code Playgroud)
mynetwork是一个覆盖网络。
现在我尝试访问容器中 docker 主机的主机名,因此我可以将主机名传递给容器中的应用程序。
我尝试使用环境变量()传递主机名--env hostname=$(hostname),但实际上${hostname}仅在管理器上执行,并且主机名设置为manager0适用于所有节点。
有没有办法访问主机名或将主机名传递给容器?