The problem I run into is that the container I would like to do this on isnt the host. The docker command doesnt work becuse the cli isnt on it.
The way that I understand it, I will have to pass the docker.sock. But im still lost how to get docker -cli installed.
so ?
ssh other_server "sudo docker container stop XXX"
rsync -avh other_server:/path/to/data /local/path/
ssh other_server "sudo docker container start XXX"
side notes:
1. exchange SSH key between servers , so you do not have password to enter
2. it's assumed that user logging to remote server is allowed to use sudo
ah - misunderstood you at one part
you try to expose file "/usr/bin/docker" to the backup container ?
so your command needs to expand with
"docker run .... -v /usr/bin/docker:/usr/bin/docker -v /var/run/docker.sock:/var/run/docker.sock ..."
plus you need to chown /var/run/docker.sock to your container ID ?
so you have docker cli inside ?
If you know the container name , you directly use the containerd to handle it , ctr containers list -a, ctr tasks kill . Problem with this is you have to recreate the container , if you are that desperate to handle this without the docker CLI then this is the way.
"docker container stop XXX" , where XXX is docker name ?
The problem I run into is that the container I would like to do this on isnt the host. The docker command doesnt work becuse the cli isnt on it. The way that I understand it, I will have to pass the docker.sock. But im still lost how to get docker -cli installed.
so ? ssh other_server "sudo docker container stop XXX" rsync -avh other_server:/path/to/data /local/path/ ssh other_server "sudo docker container start XXX" side notes: 1. exchange SSH key between servers , so you do not have password to enter 2. it's assumed that user logging to remote server is allowed to use sudo
I cannot stop another container from inside another container I need to stop it
ah - misunderstood you at one part you try to expose file "/usr/bin/docker" to the backup container ? so your command needs to expand with "docker run .... -v /usr/bin/docker:/usr/bin/docker -v /var/run/docker.sock:/var/run/docker.sock ..." plus you need to chown /var/run/docker.sock to your container ID ? so you have docker cli inside ?
No worries! I'm sorry I'm not explaining it properly. Correct! The only thing I don't have is the docker cli.
expose docker binary and try !
If you know the container name , you directly use the containerd to handle it , ctr containers list -a, ctr tasks kill. Problem with this is you have to recreate the container , if you are that desperate to handle this without the docker CLI then this is the way.
Docker compose up and down , better garbage collection