1 min readApr 22, 2020
No worries mate I think I understand now.
There are two things to consider:
- Your gitlab-runner may be running on machine A, but you want to deploy the container to machine B. So you need to find some way how you can start a container remotely on machine B, because during the job execution you’re sitting on machine A. SSH is one approach how to execute shell commands on a remote machine.
- Even if your gitlab-runner runs on the same machine as you want to deploy, you are not guaranteed that the commands you execute during the job are actually executed on that machine. That is because gitlab-runner may execute jobs in isolated environments, depending on the executor you specified when you have setup the runner. If you for example use docker as an executor (which is very common), that means for each job a docker container is created in which your commands will execute and the container will be destroyed after job termination. You to find a way to break out of the container and execute
docker run
on the host machine — one way to that is with SSH. Besides that you have the freedom to execute the job on any gitlab-runner, if you deploy with ssh that is good for portability.
I hope that answers your question, otherwise let me know.