Reputation: 158
I've moved my docker-compose container from the development machine to a server using docker save image-name > image-name.tar
and cat image-name.tar | docker load
. I can see that my image is loaded by running docker images
. But when I want to start my server with docker-compose up
, it says that there isn't any docker-compose.yml. And there isn't really any .yml file. So how to do with this?
UPDATE When I've copied all my project files to the server (including docker-compose.yml), everything started to work. But is it normal approach and why I needed to save-load image first?
Upvotes: 3
Views: 3939
Reputation: 2174
What you achieve with docker save image-name > image-name.tar
and cat image-name.tar | docker load
is that you put a Docker image into an archive and extract the image on another machine after that. You could check whether this worked correctly with docker run --rm image-name
.
An image is just like a blueprint you can use for running containers. This has nothing to do with your docker-compose.yml
, which is just a configuration file that has to live somewhere on your machine. You would have to copy this file manually to the remote machine you wish to run your image on, e.g. using scp docker-compose.yml remote_machine:/home/your_user/docker-compose.yml
. You could then run docker-compose up
from /home/your_user
.
EDIT: Additional info concerning the updated question:
UPDATE When I've copied all my project files to the server (including docker-compose.yml), everything started to work. But is it normal approach and why I needed to save-load image first?
Personally, I have never used this approach of transferring a Docker image (but it's cool, didn't know it). What you typically would do is pushing your image to a Docker registry (either the official DockerHub one, or a self-hosted registry) and then pulling it from there.
Upvotes: 1