machine icon indicating copy to clipboard operation
machine copied to clipboard

docker-machine echo fail

Open FxNion opened this issue 4 years ago • 0 comments

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.

FxNion avatar May 12 '21 09:05 FxNion