4

With the native docker client daemon, you can save images to a file and then load them.

As an example, from the docs:

$ docker save busybox > busybox.tar
$ ls -sh busybox.tar
2.7M busybox.tar
$ docker save --output busybox.tar busybox
$ ls -sh busybox.tar
2.7M busybox.tar
$ docker save -o fedora-all.tar fedora
$ docker save -o fedora-latest.tar fedora:latest

I would like to do the same functionality using docker-compose. However, it doesn't appear to support save/load in their documentation.

The reason I would like to do this is I am running docker-compose in an environment where it communicates via the docker sock, but does not have docker itself installed. I cannot install a docker client in this environment (but docker-compose is installed). Docker is not installed and does not have to be installed for docker-compose to work. ALL docker-compose requires is a connection to /var/run/docker.sock and it uses docker-py to talk over this.

I guess I could write a simple script using docker-py to do this but I am hoping to do this through docker-compose itself.

Is there a way for docker-compose to load an image file saved with docker save or to do the equivalent command?

enderland
  • 13,825
  • 17
  • 98
  • 152
  • 1
    @SimonBoudrias that's not how docker-compose works. It communicates directly on the docker sock and does not require docker itself to be installed. Docker must be installed _somewhere_ but does not necessarily have to be installed where docker-compose is. – enderland Sep 21 '16 at 02:42
  • it just a schedule tool which consume the docker API I think, so for save, it still need use docker actually. – Liping Huang Sep 21 '16 at 02:48
  • 1
    Answers go in the answers, folks. – Russia Must Remove Putin Sep 21 '16 at 02:52
  • 1
    @LipingHuang using docker-compose does not require docker installed in the environment you are using it. All it requires is a the ability to connect to the docker-api to a location a valid docker instance is working. This does not have to be in the same environment `docker-compose` is running in. – enderland Sep 21 '16 at 02:54
  • Just a note on how docker API can be used to save an image: `curl --unix-socket /var/run/docker.sock http://localhost/images/get?names=fedora >fedora.tar` ([requires](https://docs.docker.com/engine/reference/api/docker_remote_api/#/using-docker-machine-with-the-api) curl >7.40) – Honza Haering Sep 21 '16 at 08:07

1 Answers1

-2

Is there a way for docker-compose to load an image file saved with docker save or to do the equivalent command?

There is not. Your best option is to write a script with docker-py

dnephin
  • 25,944
  • 9
  • 55
  • 45