Description
openedon Oct 30, 2016
Description
Mounting a loopback device in a container requires CAP=SYS_ADMIN or even better --privileged. However, the /dev/loop* do not appear in the container when created dynamically.
This is particularly a problem when manipulating disk .img files inside a container.
I am using ubuntu:16.04 as a base to reproduce, but this should be the same with any base.
Steps to reproduce the issue:
docker run --rm -it --privileged ubuntu:16.04 bash- In container:
apt update && apt install -y gdisk - In container: make a 500MB disk file
dd if=/dev/zero of=/ofile.img bs=1M count=500 - In container: make partitions in the disk
sgdisk -n 1:2048:194559 -n 2:195560:300000 /ofile.img - In container: scan file and create loop devices for partitions:
losetup -f /ofile.img -P --show - In container: see that partition files have not been created
ls -l /dev/loop* - In host: see that partition files _have* been created:
ls -l /dev/loop*
Describe the results you received:
In container:
/dev/loop0
/dev/loop1
...
On host:
/dev/loop0
/dev/loop0p1
/dev/loop0p2
/dev/loop1
...
Essentially, when running --privileged, docker copies the /dev/ files over to the container, but does not keep them updated.
Same problem exists if you have the files before and then run losetup -D (on host or in container): on host the /dev/loop0p1 etc. files are gone, but linger in container.
Describe the results you expected:
When in privileged mode (or cap=sys_admin), since mounting is possible, devices should be synced up where relevant.
Output of docker version:
Docker version 1.12.1, build 23cf638
Output of docker info:
Containers: 1
Running: 1
Paused: 0
Stopped: 0
Images: 735
Server Version: 1.12.1
Storage Driver: aufs
Root Dir: /var/lib/docker/aufs
Backing Filesystem: extfs
Dirs: 365
Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: null bridge host overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Security Options: apparmor seccomp
Kernel Version: 4.4.0-42-generic
Operating System: Ubuntu 16.04.1 LTS
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 7.674 GiB
Name: avi-Latitude-E6320
ID: SVT2:XSJY:6LYB:O4NB:NGZO:JTXJ:MVPZ:Z2BG:JOPO:IZXS:XD2M:5FCN
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
WARNING: No swap limit support
Insecure Registries:
127.0.0.0/8
Additional environment details (AWS, VirtualBox, physical, etc.):
Physical laptop running Ubuntu.
Activity