Docker volume and docker VOLUME

I've been fiddling with docker lately and it took me a while to come to this realisation. The docker volume command line argument and the docker VOLUME Dockerfile instruction are a bit different.

The docker volume command line argument:

docker run -v /var/logs:/var/logs ubuntu echo test

And the docker VOLUME Dockerfile instruction:

VOLUME /var/logs

The Dockerfile VOLUME instruction doesn't support host directories.

As discussed in this stackoverflow post it looks like this is intentional because it makes things less portable.

Comments !

social