Use docker host usb drive to hold image, container and persistent data

27 Views Asked by At

My current development machine has limited storage space. I have several historical docker projects that I need to keep intact.

I would like to use a usb drives to hold all of the parts (images, containers, persistent data for each docker historical project.

So for example I have a USB drive MTS-Docker. It contains my docker-composer.yml file.

version: "3"

services:
  mysql:
    image: mysql:latest
    environment:
      - MYSQL_ROOT_PASSWORD=password
    volumes:
      - mysql:/var/lib/mysql
    ports:
      - 33060:3306
volumes:
  mysql:  

but the mysql image is on my host. The persistent data is on the host and I and the container is on the host. What I want is all of this to be stored on my USB drive.

As an aside, I do not want to have to reconfigure my docker installation or config file.

I can do this in a VM but would much rather do it with docker.

My development machine is Ubuntu 18.04 Docker version 24.0.2, build cb74dfc

0

There are 0 best solutions below