Search code examples
dockerbatch-filesudoplink

How to run docker load in remote server


I am trying to run docker load in a remote server. here is my code

plink.exe -ssh [email protected] -pw mypass -no-antispoof "echo mypass   | sudo -S  docker load < my-server-code.tar 2> /dev/null"

however the image doesnt get loaded

however when I run

echo mypass   | sudo -S  docker load < my-server-code.tar

from the remote server it works I do observer there are alot of loadings going on like the following

enter image description here

is that affecting the remote call?


Solution

  • To assign the docker group to your user (please note that there might be some security concerns in doing this):

    usermod -G docker $(whoami)
    

    To load the images, you can use:

    docker load -i filename.tar
    

    Another possible approach might be to define the command in the sudoers file. Check the /etc/sudoers and add something like this:

    Cmnd_Alias DOCKER_LOAD_CMD = docker load -i file.tar
    user ALL=(ALL) NOPASSWD: DOCKER_LOAD_CMD
    

    If you plan to follow this, you should check very carefully with a second terminal open if there are errors of any kind (you might break the sudo functionality and that's not fun)