Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker compose not mounting volumes

Just setup docker toolbox in Windows 10 and I am having a little issue with my docker containers. When I do docker-compose up, the instance will start but nothing is mounted in my /var/www/html directory. If I open Kitematic I see the container and when I click on volumes I do not see the local folder set. Here is what my docker-compose.yml looks like.

web:
    build: .
    ports:
        - "80:80"
    volumes:
        - app/:/var/www/html/

Do I need to specify the absolute path to my local directory? The app directory is in the same folder as the docker-compose.yml file.

like image 943
jrock2004 Avatar asked Dec 24 '15 05:12

jrock2004


People also ask

Does Docker compose create volumes?

Multiple containers can mount the same volume. Running docker-compose up will create a volume named <project_name>_html_files if it doesn't already exist . Then run docker volume ls to list the two volumes created, starting with the project name.

What is the difference between volume and mount in docker?

The most notable difference between the two options is that --mount is more verbose and explicit, whereas -v is more of a shorthand for --mount . It combines all the options you pass to --mount into one field. On the surface, both commands create a PostgreSQL container and set a volume to persist data.


2 Answers

In addition to @VonC answer, it's different when using docker-compose since the docs mention

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

like image 109
Alkis Kalogeris Avatar answered Sep 21 '22 08:09

Alkis Kalogeris


Do I need to specify the absolute path to my local directory?

Yes. The doc mentions:

The host-dir can either be an absolute path or a name value.

  • If you supply an absolute path for the host-dir, Docker bind-mounts to the path you specify.
  • If you supply a name, Docker creates a named volume by that name.

In your case, app/ would be considered as a name, not as a host folder.

like image 27
VonC Avatar answered Sep 19 '22 08:09

VonC