2

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 2

4

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
Sign up to request clarification or add additional context in comments.

4 Comments

thanks but is there any other way as to upload 400mb image, it will take 1-2 minutes.
You can gzip output. Have a look at updated answer, please.
Alternatively you could enable compression on scp command. Something like this: scp -C ./image.tar user@host:~/
yes that will work then we have first unzip file before loading via docker.
1

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

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
You are right. Save is the better command in this case. I will update my answer. Thx a lot

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.