Keep images between each tests

Hello,

I’m trying to find a way to keep images between each run with docker-compose. I know it’s possible with docke, by using cache and docker save, but it’s a little bit more complicated with docker-compose. I have this issue when I try to use a docker based job so I have to set machine: true and I can’t use setup_remote_docker.

I use this config for circleci :

defaults: &defaults
  working_directory: /home/circleci/product
  machine: true

version: 2
jobs:
  test_api:
    <<: *defaults
    steps:
      - checkout
      - restore_cache:
          keys:
            - gem-cache-{{ arch }}-{{ .Branch }}-{{ checksum "api/Gemfile.lock" }}
      - run: set -x && sudo curl -L https://github.com/docker/compose/releases/download/1.16.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose && sudo chmod +x /usr/local/bin/docker-compose
      - run: docker-compose run api bundle
      - run: docker-compose run api rake db:create
      - run: docker-compose run api rake db:schema:load
      - run: docker-compose run api rspec spec
      - save_cache:
          key: gem-cache-{{ arch }}-{{ .Branch }}-{{ checksum "api/Gemfile.lock" }}
          paths:
            - api/tmp/bundle

  test_frontend:
    <<: *defaults
    steps:
      - checkout
      - restore_cache:
          keys:
            - bower-cache
      - restore_cache:
          keys:
            - yarn-cache-{{ arch }}-{{ .Branch }}-{{ checksum "frontend/yarn.lock" }}
      - run: set -x && sudo curl -L https://github.com/docker/compose/releases/download/1.16.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose && sudo chmod +x /usr/local/bin/docker-compose
      - run: docker-compose run frontend yarn
      - run: docker-compose run frontend ember test --silent
      - save_cache:
          key: yarn-cache-{{ arch }}-{{ .Branch }}-{{ checksum "frontend/yarn.lock" }}
          paths:
            - frontend/node_modules
      - save_cache:
          key: bower-cache
          paths:
            - frontend/bower_components

workflows:
  version: 2
  build_and_test:
    jobs:
      - test_api
      - test_frontend

What is the best solution ?