Deploying docker-compose the easy way, without registry or scp

Deploying docker-compose the easy way, without registry or scp

Ever wondered how you can deploy your locally running docker-compose project to a remote server? There are several options:

  1. Pushing the images to a container registry like dockerhub, github container registry and pulling them onto your server

  2. Saving the images to a .tar archive and copying it over to your server and loading them there is explained here

There is an easier way using docker remote host:

The only thing you have to make sure is to install docker, docker-compose onto your server and have a valid SSH key


version: '3.9'
    build: spring-backend
    container_name: spring-backend
    image: spring-backend:0.0.1
      - "8088"
    build: angular-frontend
    image: angular-frontend:0.0.1
    container_name: angular-frontend
      - 80:80
      - backend
    command: [nginx-debug, '-g', 'daemon off;']


docker-compose build

for img in $(docker-compose config | awk '{if ($1 == "image:") print $2;}'); do
  images="$images $img"

echo $images

docker image save $images | docker -H "ssh://user@serverIp" image load
docker-compose -H "ssh://user@serverIp" up --force-recreate -d
docker-compose -H "ssh://user@serverIp" logs -f
read -p "Press any key to continue... " -n1 -s

With a simple you can build your current state, load them onto your server, run them, and attach to the output.