> For the complete documentation index, see [llms.txt](https://docs.shakiba.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.shakiba.net/container/docker/moving-docker-images-around-using-ssh-and-pipe.md).

# moving docker images around using ssh and pipe

how to move docker images around using ssh and pipe

For moving some docker images around, or VPN `.conf` files; sometimes I do this:

#### from local to remote

```
docker save alpine:latest | ssh remote-host "cat - | docker import - alpine:latest"
```

* `docker save alpine:lates` export or save file
* `ssh remote-host` ssh to remote-host
* `cat - |` read from STDIN and pipe it
* `docker import - alpine:latest` read from STDIN and save it

Then `alpine:latest` will be available on remote-host

#### from remote to local

```
docker import - getmeili/meilisearch < <(ssh remote-host docker save getmeili/meilisearch)
```

* `ssh remote-host` ssh to remote-host
* `docker save getmeili/meilisearch` run this command
* `<(CMD)` redirect the output back to STDIN
* `<` read from STDIN
* `docker import - getmeili/meilisearch` read from STDIN

Then `getmeili/meilisearch` will be available on local host.

#### from remote to another remote (by help of a local)

```
cat - < <(ssh remote-host-1 "cat /home/pf/configs/shf.conf") | ssh remote-host-2 "cat - > /tmp/shf.conf"
```

In this style, I download `shf.conf` file from the remote-host (1) and without write it to desk sent it to another remote-host (2).

```
[ remote-1 ] => [ local (mypc)] => (remote-2)
```

Actually we can omit `cat - <` and use:

```
ssh remote-host-2 "cat - > /tmp/shf.conf" < <(ssh remote-host-1 "cat /home/pf/configs/shf.conf")
```

And this also sends newline if we be prompt for password , so the third version is better:

```
ssh remote-host-1  "cat /home/pf/configs/shf.conf" | ssh remote-host-2 "cat - > /tmp/shf.conf"
```

{% hint style="info" %}
`if docker import` gives us error when running the container, we can use `docker load` instead
{% endhint %}
