docker / machine

Machine management for a container-centric world
https://docs.docker.com/machine/
Apache License 2.0
6.62k stars 1.97k forks source link

docker-machine echo fail #4888

Open FxNion opened 3 years ago

FxNion commented 3 years ago

Suppose you want to script file conf enhancement from you host to your docker-machine instance: For all the cases below, no file is created as expected

docker-machine ssh mymachine echo test_string > test.txt 
docker-machine ssh mymachine echo test_string | tee test.txt 
docker-machine ssh mymachine bash -c "echo test_string > test.txt"
docker-machine ssh mymachine bash -c "echo test_string | tee test.txt" 
docker-machine ssh mymachine sudo bash -c "echo test_string > test.txt"
docker-machine ssh mymachine sudo bash -c "echo test_string | tee test.txt"
docker-machine ssh mymachine sudo bash -c "echo test_string | sudo tee test.txt"

Wether the file test.txt exists on the machine, a blank line is appended instead of the expected string with the commands below:

docker-machine ssh mymachine echo test_string >> test.txt  
docker-machine ssh mymachine echo test_string | tee test.txt
docker-machine ssh mymachine bash -c "echo test_string >> test.txt" 
docker-machine ssh mymachine bash -c "echo test_string | tee -a test.txt" 
docker-machine ssh mymachine sudo bash -c "echo test_string >> test.txt" 
docker-machine ssh mymachine sudo bash -c "echo test_string | tee -a test.txt" 
docker-machine ssh mymachine sudo bash -c "echo test_string | sudo tee -a test.txt" 

Tested with the driver openstack, on Debian buster, updated.