'How to stop and start Docker container from bash script Synology?
Hey guys so I'm on a synology DS218+ and I'm running docker and hosting my own instance of gitlab in it.
So now I'm trying to write an update Script with bash.
docker stop gitlab_td3v
rm -rf /volume1/docker/"gitlab"
rm -rf /volume1/gitlab/"gitlab_backup.rb"
cp -r /volume1/gitlab /volume1/docker/"gitlab"
cp /volume1/gitlab/config/gitlab.rb /volume1/gitlab/"gitlab_backup.rb"
docker rm -f gitlab_td3v
docker pull gitlab/gitlab-ee:latest
docker run --detach --hostname Myhost.name --name gitlab_td3v --publish ..:.. --publish ..:.. --publish ..:.. --restart always --volume /volume1/gitlab/config:/etc/gitlab --volume /volume1/gitlab/data:/var/opt/gitlab --volume /volume1/gitlab/logs:/var/log/gitlab gitlab/gitlab-ee:latest
The problem I have now as you can see in the image I'm trying to stop and remove the container but It doesn't recognise it's name, but if I echo docker ps
in the file it gives me the container with the name I used in the file.
CLI
Also when I just run the commands in the bash shell it works only as soon as I try to run the file it doesn't work and now I'm really confuse cause I made sure I'm on the same user on the same shell and everything and that I am but in the file it won't let me select the container over the name or the id I get from docker ps.
So now the question I guess is did anyone have the same problem or does anyone know a fix for it?
Would really appreciate it thanks.
Solution 1:[1]
The script must be executed as root.
docker stop CONTAINERNAME
CONTAINERNAME is definied by value "NAME"
See by
docker stats
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Jerome2103 |