1

I am trying to copy container from one host to other with its's volumes. I am trying to copy the below mention script but but facing issue docker-volumes.sh : command not found

Another query is what to be inserted instead of $USER@$HOST:

# Stop the container   
docker stop $CONTAINER

# Create a new image   
docker commit $CONTAINER $CONTAINER

# Save image
docker save -o $CONTAINER.tar $CONTAINER

# Save the volumes (use ".tar.gz" if you want compression)
**docker-volumes.sh** $CONTAINER save $CONTAINER-volumes.tar

# Copy image and volumes to another host
scp $CONTAINER.tar $CONTAINER-volumes.tar $USER@$HOST:

# On the other host:
docker load -i $CONTAINER.tar
docker create --name $CONTAINER [<PREVIOUS CONTAINER OPTIONS>] $CONTAINER

# Load the volumes
docker-volumes.sh $CONTAINER load $CONTAINER-volumes.tar

# Start container
docker start $CONTAINER

I want to copy container from one host to other but with its data/volumes

  • Did you get that example from this answer - https://stackoverflow.com/a/53068212/5284011? There is a link there to the ``docker-volumes.sh`` script. It is a custom thing written by the contributor. – JohnXF Nov 16 '22 at 10:04
  • Usually committing a container to an image isn't a good idea; it leads to images that can't be rebuilt from source, and in the workflow you suggest, you can very easily have different containers and images on different machines that look similar but could have literally anything in them. Can you [copy the data](https://docs.docker.com/storage/volumes/#back-up-restore-or-migrate-data-volumes), and then run new containers on the target system from the same image, and delete the existing containers? – David Maze Nov 16 '22 at 11:11

0 Answers0