my requirement is that I want to put an image in the host"s fixed directory (it"s up to me to decide exactly where, not docker), and then reference it through docker-compose.yml
).suppose
a/docker-compose.yml
b/docker-compose.yml
c/docker-compose.yml
should refer to the picture. I don"t want to map the directory structure in every file. I just want to refer to it through the name of volume. In this way, I can modify the storage path of the picture, and there is no need to modify other files
.what can be done now
sudo docker volume create --name=data
version: "2"
volumes:
data:
external: true
services:
test:
image: alpine
container_name: c_test
command: /bin/sh
tty: true
volumes:
- data:/tmp
I can get the image storage path by the name data in docker-compose.yml. The disadvantage is that its path is
./var/lib/docker/volumes/data/_data
is not what I want. I want to customize this storage path