CM2Walki / steamcmd

Minimal image containing Valve's SteamCMD binary: https://hub.docker.com/r/cm2network/steamcmd/

Home Page:https://CM2.Network

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

VOLUME uselessly copies data to host

gdlx opened this issue · comments

I'm using your TF2 image relying on this one, but the VOLUME ${STEAMCMDDIR} command causes the image contents to be copied on the host in an anonymous volume with ~300MB, and this is duplicated each time the container is restarded, finally causing a huge and useless disk usage or requires regular cleanup:

root@homesrv:/var/lib/docker/volumes/c0501b78b12a806a75c0c954da4b4cb81ff0e6149bd960a6690f32d201c1a432# du -sh *
316M    _data
root@homesrv:/var/lib/docker/volumes/c0501b78b12a806a75c0c954da4b4cb81ff0e6149bd960a6690f32d201c1a432# ll _data
total 32
drwxr-xr-x 7 homesrv homesrv 4096 nov.  20 22:19 ./
drwxr-xr-x 3 root     root     4096 nov.  20 22:18 ../
drwxr-xr-x 2 homesrv homesrv 4096 nov.  20 22:19 linux32/
drwxr-xr-x 2 homesrv homesrv 4096 nov.  20 22:19 linux64/
drwxr-xr-x 2 homesrv homesrv 4096 nov.  20 22:19 package/
drwxr-xr-x 2 homesrv homesrv 4096 nov.  20 22:19 public/
drwxr-xr-x 3 homesrv homesrv 4096 nov.  20 22:18 siteserverui/
-rwxr-xr-x 1 homesrv homesrv 1166 oct.  10  2016 steamcmd.sh*
lrwxrwxrwx 1 homesrv homesrv   32 août  25 09:15 steam.sh -> /home/steam/steamcmd/steamcmd.sh

Overwriting this volume with a customized host directory doesn't work because in this case, the image contents is not copied, so the directory is empty and the image doesn't start.

Is there any good reason for duplicating the image contents on the host, knowing it doesn't bring persistence between container executions or would it be possible to remove this VOLUME instruction ?

Thanks!

Hey @gdlx,

I assume with restarting you mean recreating the container which causes it to allocate a new volume (which is intended behaviour). The image doesn't have bind mount support, as you already noticed, because it really doesn't need it. What you are looking for is a named volume:

$ docker volume create steamcmd_volume # Create named volume
$ docker run -it -v "steamcmd_volume:/home/steam/steamcmd" --name=steamcmd cm2network/steamcmd bash # Start the container with the volume mounted

This way it will remain persistent over container recreations. You can even mount the same named steamcmd volume into multiple containers. That way you save space by using the same installation for multiple game servers. (I used this extensively in my steampipe image).

As to the reason why the VOLUME instruction is there, simply because a steamcmd installation is not static content, each time you launch it, it updates itself. Remember in the regular docker storage driver it will create a new layer for every change. So each update to steamcmd would keep growing the layers unnecessarily.