Mount bind - long vs short syntax

I only use Docker compose, in Openmediavault’s plugin for it, and my knowledge of how Docker works is only growing at a modest pace…

I’m now investigating how to get a Jellyfin container up and running, and this seems a logical starting point: Container | Jellyfin

But a few lines are other than what I’m used to:

volumes:
      - /path/to/config:/config
      - /path/to/cache:/cache
      - type: bind
        source: /path/to/media
        target: /media
      - type: bind
        source: /path/to/media2
        target: /media2
        read_only: true

I’m only used to lines like - /path/to/config:/config, so I started googling about this ‘bind type’. As far as I can find, what I’ve been using have always been ‘mount binds’, and this article wants to make me believe that the two syntax types actually result in the same thing: Warp: How To Create Bind Mounts With Docker Compose Volumes

But it seems so peculiar that two different types of syntax would be used in the same example. So I wanted to double check that…

Is - /path/to/media2:/media2 the same as

- type: bind
        source: /path/to/media2
        target: /media2

?

i would always start with official documentations

I also wrote about volumes and bind mounts where I linked the documentation as well.

The single line syntax (short syntax) is the original, old syntax and it was kept for compatibility reason and because it is easier when you just try things out. It doesn’t support all the features you can use with the long syntax, like deciding whether you want a folder to be created automatically on the host when the source path does not exist or not. The default is “not”. Recently I prefer the long syntax.

But you can find other things in Docker that can be done multiple ways. For example docker run was the original syntax, but you can also use docker container run. Originally there was docker build, but you can also use docker image build. The original commands were kept and when I’m using docker commands in scripts, I prefer the longer commands which are more obvious, but when I’m typing the commands interactively, I often use the shorter commands..

1 Like

Check the output of docker compose config.

It will show the actual compose file configuration used for the deployment. You will notice that every short syntax declaration is replaced by its long syntax equivalent, regardless whether its a volume or port mapping.

Thanks for the info!