Unable to format the un-mounted mmc partition when dockerd(17.06 version) is running in background

Hi All,

I am booting my ARM based target with yocto-2.4. In which linux version is 4.14. Yocto-2.4 is having support of docker-17.06.0. We observed that when we tried to format the unmounted mmc partition than it give error “/dev/mmcblk1p1 is apparently in use by the system; will not make a filesystem”. And when we stop running the dockerd than only we are able to format the unmounted partition.

Kindly request you to please share some pointer to fix this issue. Please find steps below to reproduce this issue.

umount /run/media/mmcblk1p1

mkfs.ext3 /dev/mmcblk1p1

mke2fs 1.43 (17-May-2016)
/dev/mmcblk1p1 contains a ext3 file system
last mounted on / on Wed Jan 16 20:13:04 2019
Proceed anyway? (y,n) y
/dev/mmcblk1p1 is apparently in use by the system; will not make a filesystem
here!

ps -el | grep dock

4 S 0 2421 1 0 80 0 - 11164 futex_ ? 00:01:57 dockerd
4 S 0 2437 2421 0 80 0 - 4351 futex_ ? 00:00:13
docker-containe

/etc/init.d/docker.init stop

Stopping docker: [ OK ]

mkfs.ext3 /dev/mmcblk1p1

mke2fs 1.43 (17-May-2016)
/dev/mmcblk1p1 contains a ext3 file system
last mounted on / on Wed Jan 16 20:13:04 2019
Proceed anyway? (y,n) y
Discarding device blocks: done
Creating filesystem with 1835008 4k blocks and 458752 inodes
Filesystem UUID: f6895018-e0c6-4627-a269-235768723a96
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

/etc/init.d/docker.init restart

Stopping docker: [ OK ]
Docker doesn’t support using NFS filesystem as container layer with overlay
storage driver.
Boot target other than NFS to use docker with overlay storage driver.
*** For now, running docker with devicemapper as storage driver ***
Starting docker: [ OK ]

[ 3202.499628] device-mapper: thin: Data device (loop0) discard

unsupported: Disabling discard passdown.

During further investigation we found this issue due to “unshare -m” option passing in /etc/init.d/docker.init script file. When we remove or replace “-m” with other option, e.g “-u”(unshare UTS name space) and than restart the /etc/init.d/docker.init script than we are able to format the unmounted mmcblk1p1 partition. E.g below

“$unshare” -u – $exec $other_args &>> $logfile & /etc/init.d/docker.init

Now question what is purpose of passing “-m” option in docker script ? Is it compulsory to pass ?