Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dockerfile filepaths: what does the colon mean?

Tags:

In Dockerfiles and docker-compose files I often stumble across two notations.

Example docker-compose:

volumes:
      - ./app/:/usr/src/app/

Example Dockerfile

COPY ./Pipfile /usr/src/app/Pipfile

The second one means, take the file/folder from my machines directory ./Pipfile and Copy it to the image in the directory /usr/...? But what does the first one mean?

Thanks.

like image 555
Xen_mar Avatar asked Mar 14 '19 05:03

Xen_mar


1 Answers

https://docs.docker.com/storage/images/types-of-mounts-volume.png

In the case of a bind mount

-v or --volume: Consists of three fields, separated by colon characters (:).
The fields must be in the correct order, and the meaning of each field is not immediately obvious.

  • In the case of bind mounts, the first field is the path to the file or directory on the host machine.
  • The second field is the path where the file or directory is mounted in the container.
  • The third field is optional, and is a comma-separated list of options, such as ro, consistent, delegated, cached, z, and Z. These options are discussed below.

In case of named volume: the first field is the name of the volume, and is unique on a given host machine. For anonymous volumes, the first field is omitted.

Here: the first argument is a path, /app/: so bind mount it is.

like image 171
VonC Avatar answered Oct 20 '22 17:10

VonC