Score:1

Rsync or scp from/to a Docker containerized shell

id flag

I want users can access via ssh to a container. Or, more precisely: host users can access to a containerized shell. This could look strange, but it works:

$ cat /etc/passwd | grep staging

staging:x:1001:1001::/home/staging:/usr/local/bin/stagingclish
$ groups staging

staging : staging docker
$ cat /usr/local/bin/stagingclish 

#!/bin/sh
cd /home/cloud/docker/myproject-staging && docker-compose run --rm --entrypoint=bash php-cli $@

php-cli is just a custom build from php:7.4-cli image, including some utilities like rsync. Also, /etc/passwd is mounted from host.

I can login with ssh staging@myhost.

I can invoke commands:

ssh staging@myhost ls /

Creating myproject-staging_php-cli_run ... 
Creating myproject-staging_php-cli_run ... done
CHANGELOG.md
COPYING.txt
Gruntfile.js.sample
...

Now I would like be able to use scp and rsync commands to retrieve/upload files from/to the container.

But:

scp staging@myhost:/var/www/repo/auth.json.sample .

Creating myproject-staging_php-cli_run ... 
Creating myproject-staging_php-cli_run ... done
usage: scp [-346BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]
           [-l limit] [-o ssh_option] [-P port] [-S program] source ... target
1

And

rsync staging@myhost:/var/www/repo/auth.json.sample .

[... rsync help ...]

rsync error: syntax or usage error (code 1) at main.c(1580) [client=3.1.3]
1
rsync: connection unexpectedly closed (0 bytes received so far) [Receiver]
rsync error: error in rsync protocol data stream (code 12) at io.c(228) [Receiver=3.2.3]

I don't even know if this is possible. Could anyone bring some light?

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.