I don't want to push a docker build image to DockerHub. Is there any way to directly deploy a docker image from CircleCI to AWS/vps/vultr without having to push it to DockerHub?
2 Answers
I use docker save/load commands:
# save image to tar locally
docker save -o ./image.tar $IMAGEID
# copy to target host
scp ./image.tar user@host:~/
# load into target docker repo
ssh user@host "docker load -i ~/image.tar"
# tag the loaded target image
ssh user@host "docker tag $LOADED_IMAGE_ID myimage:latest"
PS: LOADED_IMAGE_ID can be retrieved in following way:
REMOTE_IMAGE_ID=`ssh user@host"docker load -i ~/image.tar" | grep -o "sha256:.*"`
Update: You can gzip output to make it smaller. (Don't forget unzip the image archive before load)
docker save $IMAGEID | gzip > image.tar.gz
4 Comments
itsyub
thanks but is there any other way as to upload 400mb image, it will take 1-2 minutes.
i.bondarenko
You can gzip output. Have a look at updated answer, please.
i.bondarenko
Alternatively you could enable compression on scp command. Something like this:
scp -C ./image.tar user@host:~/itsyub
yes that will work then we have first unzip file before loading via docker.
You could setup your own registry: https://docs.docker.com/registry/deploying/
Edit: As i.bondarenko said, docker save/load are the better commands for your needs.
2 Comments
i.bondarenko
Docker export is used to persist a container (not an image). For docker image docker save is suitable. docs.docker.com/engine/reference/commandline/save
dschuldt
You are right. Save is the better command in this case. I will update my answer. Thx a lot