TransWikia.com

Is it normal for Docker to create so many mounts and not clean them up?

Server Fault Asked by djskinner on February 3, 2021

I’ve recently provisioned a server with Ubuntu 14.10 and Docker CE using the overlay2 storage driver. After running a few containers my df -h output looks like this:

root@dev1:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root        20G   12G  7.2G  62% /
devtmpfs        492M     0  492M   0% /dev
tmpfs           495M     0  495M   0% /dev/shm
tmpfs           495M  9.4M  486M   2% /run
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           495M     0  495M   0% /sys/fs/cgroup
overlay          20G   12G  7.2G  62% /var/lib/docker/overlay2/c8a64b3d90888c734f0ac8b6854cabfdcf238e716f39080450a5abd85b5e371b/merged
shm              64M     0   64M   0% /var/lib/docker/containers/250094a88d3d6f3af5dbc3cf93636e382092e160c944f02c5008d07909f7a620/shm
overlay          20G   12G  7.2G  62% /var/lib/docker/overlay2/9222282cf5f4274f50623b02c07e6863442cdb385117a3c9b1a98e52273af8ad/merged
shm              64M     0   64M   0% /var/lib/docker/containers/465d0f2a73f9005dbea7281b9fa0b553c3e99e49107b250172fade3764052e5a/shm
overlay          20G   12G  7.2G  62% /var/lib/docker/overlay2/4f6340df52e9828bfc8d7c70a95ad6f8e7d9204a7a718ed4f72b9f6e91cc075a/merged
shm              64M     0   64M   0% /var/lib/docker/containers/46cd1080275a6a3f649330cfdff69e03ff8099fb31d81b736f3ffdc447c8a375/shm
overlay          20G   12G  7.2G  62% /var/lib/docker/overlay2/a8ffd7344def30e0bde1caa80c0597c51663e3684b5e8deb4deb9ecf1395aea2/merged
shm              64M     0   64M   0% /var/lib/docker/containers/e40bd327b2ad3017d7350b1817de1d58cba42993eaa5dc4db5259a66fae29e44/shm
overlay          20G   12G  7.2G  62% /var/lib/docker/overlay2/2520e792b3e86f6da1f8ece8b68cf5cea1f25c5da219fce579fc2a142d381af4/merged
shm              64M     0   64M   0% /var/lib/docker/containers/b1f626492cc5ae1ad241f521f11279705740261fbda71e38c134be61c3247830/shm
overlay          20G   12G  7.2G  62% /var/lib/docker/overlay2/c4cb8bb4bb444272db2172c6409514d61a443ae26ce18b4b87b9e2813f60758e/merged
shm              64M     0   64M   0% /var/lib/docker/containers/6566daf418ccd3021410719c29aa202041769749ae027f3ee2f0db431613a547/shm
overlay          20G   12G  7.2G  62% /var/lib/docker/overlay2/832ebb7c4641ef2cdb0708418110c400a63324cf2b4a489da2a4fcf565a00de1/merged
shm              64M     0   64M   0% /var/lib/docker/containers/8be7d0b8c449377fe51a5d581d438e07136e776ba67a434b5fe9338691afc811/shm
overlay          20G   12G  7.2G  62% /var/lib/docker/overlay2/b48976d701f72245535d00035c31f67c06b163a6adf3cfa0aa65d7d9d635be76/merged
shm              64M     0   64M   0% /var/lib/docker/containers/1562126d1a41675f66ed4fa06885d81ef9f629ecb26905670d0a1ba547f34b37/shm
overlay          20G   12G  7.2G  62% /var/lib/docker/overlay2/54a7a1647e89b61bb1f43a29a9ca20e082efa834c062c9c92da84ac301637eb0/merged
shm              64M     0   64M   0% /var/lib/docker/containers/2b069b9034223177fda4fd28a56b1d5efa32f1b9206e051c8b1e0f7a8bc18349/shm
tmpfs            99M     0   99M   0% /run/user/0
overlay          20G   12G  7.2G  62% /var/lib/docker/overlay2/2bf5497b1743bf260cfb8e3619d8587a3b47f46633f3a8704ec1ef7a0725541a/merged
shm              64M     0   64M   0% /var/lib/docker/containers/8dcc013097a7a20f4c0b5833bb5b3d256876528c22d3484f849d52b55a6eb44a/shm
overlay          20G   12G  7.2G  62% /var/lib/docker/overlay2/8a8a920c984ca0db9da745647900b3020fac173442bf268110ba06938be755b2/merged
shm              64M     0   64M   0% /var/lib/docker/containers/817a36bea3f79610b04d7ade9d16c122c30f7ff981996d17e556c95f16c5c102/shm
overlay          20G   12G  7.2G  62% /var/lib/docker/overlay2/cd3e9dad0a7e6e9eaadf10816c4bd4e3fc0fb0134264c43aaac47da192c2933a/merged
shm              64M     0   64M   0% /var/lib/docker/containers/0af08a186eaa6d42c89af4728fb66b48ab32350fab0e19d68c7916c753255a45/shm
overlay          20G   12G  7.2G  62% /var/lib/docker/overlay2/fd0e0505f9112f5ee239f06f7833694d37c9b473dc32bd1d367fb8042af75198/merged
shm              64M     0   64M   0% /var/lib/docker/containers/0270c05504523225206f37e85dca3915ca68def7a1e0aa148e5be0124a845b0e/shm
overlay          20G   12G  7.2G  62% /var/lib/docker/overlay2/17f2a5db405350215cc432ff21f88acc699e8dbd879d1e3edb4bb40e0d9d09e2/merged
shm              64M     0   64M   0% /var/lib/docker/containers/0d9f0ce27b16363262cc9735734d3332c9e356c8aef1bf2a4a1ff05b085b231f/shm
overlay          20G   12G  7.2G  62% /var/lib/docker/overlay2/44aae49e079d49db1447e09806ed8c697f25ac056d64325937c2d7e2cf9598f7/merged
shm              64M     0   64M   0% /var/lib/docker/containers/8108b6034e92ec0e1f7d90785c907148d5d2950be4b0573fc470c2587fb68337/shm
overlay          20G   12G  7.2G  62% /var/lib/docker/overlay2/b7da3582b33c6b8d72ff7af6295b653484e97877502abcf1f5b83dce25ac3c41/merged
shm              64M     0   64M   0% /var/lib/docker/containers/d707a2374f92f056b0ba1055a0055316f67a4300b73e0646204f8cf206f0de28/shm

Even when I do docker system prune to clear everything these mount points just don’t go. I seem to be gathering more and more of them and there’s no obvious way to get rid of them.

Is this normal/expected behaviour?

docker info:

Containers: 16
 Running: 14
 Paused: 0
 Stopped: 2
Images: 16
Server Version: 17.03.1-ce
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 4ab9917febca54791c5f071a9d1f404867857fcc
runc version: 54296cf40ad8143b62dbcaa1d90e520a2136ddfe
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.9.15-x86_64-linode81
Operating System: Ubuntu 16.10
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 989 MiB
Name: dev1
ID: KWTP:NAOT:CGDG:HBCS:UOVG:H3XZ:IW7C:5EJA:IZI7:ROFZ:EHHU:TQNL
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
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

Docker installation script:

#!/bin/bash

# Install packages to allow apt to access a repository over https
sudo apt-get -y install 
    apt-transport-https 
    ca-certificates 
    curl 
    software-properties-common

# Add Dockers official GPG key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

# Verify that the key fingerprint is 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
sudo apt-key fingerprint 0EBFCD88

# Set up the stable repository
sudo add-apt-repository 
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu 
   $(lsb_release -cs) 
   stable"

# Update the apt package index.
sudo apt-get update

# Latest version of Docker
sudo apt-get -y install docker-ce

# Configure Docker FileSystem
mkdir -p /etc/systemd/system/docker.service.d
cat > /etc/systemd/system/docker.service.d/overlay2.conf <<EOF
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -H fd:// --storage-driver=overlay2
EOF

# Add users to docker group
usermod -aG docker $(whoami)
usermod -aG docker $SUDO_USER

reboot

2 Answers

Containers: 16
 Running: 14
 Paused: 0
 Stopped: 2

These mounts are used by running containers. In your info it appears you have 14 running containers. A prune command will not stop and delete running containers, so that isn't expected to cleanup these mounts. To remove the mount you need to stop and delete the container. Use:

docker container ls # list containers
docker container stop $container_id # stop the container
docker container rm $container_id # delete the container

Note that deleting a container deletes all logs, configuration of that container, and anything written to the container filesystem. It will not delete volumes unless the volume is an anonymous volume and the container is started with the --rm option.

Answered by BMitch on February 3, 2021

I was experiencing this same issue recently on Ubuntu 20.04 with Docker v19.03.13. I searched through Docker docs and found that this maybe because of a new type of filesystem they introduced. You can read more about it from here. The way I fixed it was by editing (creating if not present already) the /etc/docker/daemon.json file and adding the following lines:

{
  "storage-driver": "overlay"
}

Then restarting docker using the following command:

sudo systemctl restart docker

Answered by zean_7 on February 3, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP