Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker Named Volume location Mac

I'm using Docker for Mac 1.12.1 and have a Docker Compose file which starts WordPress and MySQL services

Compose file

version: '2'
services:
  db:
    container_name: mysql_db
    image: mysql:5.7
    volumes:
      - "./.data/db:/var/lib/mysql"
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: wordpress
      MYSQL_DATABASE: wordpress
      MYSQL_USER: wordpress
      MYSQL_PASSWORD: wordpress

  wordpress:
    container_name: wordpress
    depends_on:
      - db
    image: wordpress:latest
    links:
      - db
    ports:
      - "8000:80"
    restart: always
    environment:
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_PASSWORD: wordpress
    volumes:
      - wordpress/:/var/www/html/

volumes:
    wordpress:

However, after bringing everything up successfully, I cannot find where the named volume exists on my Mac.

MacBookAir:wordpress carlwainwright$ docker volume inspect wordpress_wordpress
[
    {
        "Name": "wordpress_wordpress",
        "Driver": "local",
        "Mountpoint": "/var/lib/docker/volumes/wordpress_wordpress/_data",
        "Labels": null,
        "Scope": "local"
    }
]
MacBookAir:wordpress carlwainwright$ ls -l /var/lib/docker/volumes/wordpress_wordpress/_data/
ls: /var/lib/docker/volumes/wordpress_wordpress/_data/: No such file or directory

Any ideas?

like image 688
Carl Wainwright Avatar asked Nov 29 '22 00:11

Carl Wainwright


1 Answers

Please keep in mind, Docker for Mac runs a docker engine in a Linux VM, not your Mac OS, so you can't find the volume's mount point in your Mac OS file system. The volume files should existing in that Linux VM's file system.

However, you can login Docker for Mac's VM via screen:

$ screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty  
#user: root
#password: xxxxxx

Then you can view the docker's volumes:

$ ls -ltrh /var/lib/docker/volumes
total 148
drwxr-xr-x    3 root     root          4096 May 16 13:20 04576d248c19b1210d47e94c8211493428cd3c3aa71dfe3fa0f4214589a6f875
drwxr-xr-x    3 root     root          4096 May 16 13:20 31af0f01492d8f7b832dad75e731b754302e84fbecfa7c654d7de10465bec204
etc.
like image 111
Haoming Zhang Avatar answered Dec 04 '22 02:12

Haoming Zhang