0leg
0leg

Reputation: 14144

Dot and colon meaning

What does dot-colon .:

- .:/var/www/project:cached

mean in situation like this:

version: '3'
services:
  php:
    image: php:7.1-fpm
    ports:
      - 9000
    volumes:
      - .:/var/www/project:cached

Is this part of bash syntax or is it part of Docker syntax (haven't found any info on both).

Upvotes: 21

Views: 9908

Answers (2)

tgogos
tgogos

Reputation: 25152

  • . is used for "current directory"
  • : is used to separate the host's path from container's path. (Each volume uses a source path for the host and a destination path for the container).
  • :cached seems to be a caching option for docker-for-mac

From the docs:

Short syntax

Optionally specify a path on the host machine (HOST:CONTAINER), or an access mode (HOST:CONTAINER:ro).

You can mount a relative path on the host, that expands relative to the directory of the Compose configuration file being used. Relative paths should always begin with . or ...

Upvotes: 26

eyevan
eyevan

Reputation: 1473

As per documentation:

Optionally specify a path on the host machine (HOST:CONTAINER), or an access mode (HOST:CONTAINER:ro).

You can mount a relative path on the host, that expands relative to the directory of the Compose configuration file being used. Relative paths should always begin with . or ...

The . is a directory where docker-compose file is located. It will be mounted to the path after the colon.

Upvotes: 6

Related Questions