N
N
NkDev2018-03-15 14:33:18
linux
NkDev, 2018-03-15 14:33:18

Docker: how to change the default address of a named volume?

At the root of the project is the docker-compose.yum file :

version: '3.5'
services:
    db:
        container_name: my_db
        image: mysql
        ports:
            - "3306:3306"
        volumes:
            - "mysql:/var/lib/mysql"
        environment:
            MYSQL_ROOT_PASSWORD: 12345
            MYSQL_DATABASE: test
            MYSQL_USER: vlad
            MYSQL_PASSWORD: 12345

volumes:
    mysql:

After docker-compose up -d --build , a corresponding volume is created on the host in the directory: /var/lib/docker/volumes/
Question:
How can I change this address from the default to my own?
Those. I want this volume to be created not at the address /var/lib/docker/volumes/ , but at the address, for example, /home/vlad/my_project/mysql . I want to store all project files in one place!
Thanks!!!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
Hikmat Abdunabiev, 2018-03-15
@Khikmat

Have you tried specifying volumes like this:

volumes:
  - "/home/vlad/my_project/mysql:/var/lib/mysql"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question