rundeck-plugins / docker

Providers for docker
29 stars 24 forks source link

Docker run image in a remote node #41

Open lukasged opened 5 years ago

lukasged commented 5 years ago

Hi,

I'm trying to use this Rundeck plugin to run containers on remote nodes (currently I'm doing the same task but manually defining a bash script step which is run on remote nodes and will run 'docker run' there).

The problem is that I get the following error:

Traceback (most recent call last):
  File "/var/lib/rundeck/libext/cache/docker-container-1.4.1/run-image", line 93, in <module>
    stderr=STDOUT
  File "/usr/lib64/python2.7/subprocess.py", line 711, in __init__
    errread, errwrite)
  File "/usr/lib64/python2.7/subprocess.py", line 1327, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory
Failed: NonZeroResultCode: Script result code was: 1
Execution failed: 24 in project *****: [Workflow result: , step failures: {1=Dispatch failed on 1 nodes: [****: NonZeroResultCode: Script result code was: 1 + {dataContext=MultiDataContextImpl(map={}, base=null)} ]}, Node failures: {******=[NonZeroResultCode: Script result code was: 1 + {dataContext=MultiDataContextImpl(map={}, base=null)} ]}, status: failed]

Is there any requirement for what is expected to be installed on my remote node which is the one running the job?

Thanks

JoeJenningsDMC commented 5 years ago

I'm also after this functionality.

colegatron commented 5 years ago

After days having issues running containers with Kubernetes plugin I switched to docker in docker in order to get containers running and I found this bug :-(

Would be great to have it fixed

rhiscar commented 4 years ago

Has anyone found a workaround on this? I would like to use this funcionality to scalate my rundeck farm.

stefan-marc commented 3 years ago

Hi,

Not sure if the solution to this problem is still needed after all this time, but maybe it will help someone. I ran into this problem while setting up rundeck inside a docker container and trying to use the docker plugin.

Found this post that helped me figure it out: https://github.com/rundeck-plugins/docker/issues/3

The problem is (and no it's not a bug), the docker plugin is a bit miss-understood. I thought (same as you) that the plugin executes docker commands on the node you're targeting. It actually doesn't. It executes them locally where rundeck is installed. In our case inside the container. Not what you expected? It was a shocker for me as well...

You can test this by exec-ing inside the container and executing the following command. /home/rundeck/libext/cache/docker-container-1.4.1/python run-image ubuntu pwd The output is the error you posted.

To actually get it working, you have to do the following: In your rundeck docker image install docker cli

RUN curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
RUN add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
RUN apt-get -y update && apt-get -y install docker-ce-cli && \
    apt-get clean && \
    rm -rf /var/lib/apt-lists/*

Also create the docker group and add the rundeck user to that group (this will allow rundeck to execute docker commands without getting permission errors)

RUN groupadd -for -g 116 docker && \
    usermod -aG docker rundeck

Run the image with the following volume mounted /var/run/docker.sock:/var/run/docker.sock:ro

Should be working :).

This is not ideal. Why? because from what I can see you can't create containers using this plugin on other nodes except the one hosting your container, which wasn't what I expected. Plus the security concerns it introduces... again not ideal. I'm still wrapping my head around how to setup the node executor part. Maybe I'll find something interesting.

cloudlady911 commented 3 years ago

I did as you described here, but it did not work for me. Not sure if it matters but my dockerfile is based on rundeck 3.3.9 FROM rundeck/rundeck:3.3.9 Your actual install script failed. So I installed with this:

RUN curl -sSL https://get.docker.com/ | sh
RUN usermod -aG docker rundeck

Docker gets installed but will not run.

I executed into the docker container that is running Rundeck. I am running as root

I ran the following:

service docker status
 * Docker is not running

Manually started:

service docker start
 * Starting Docker: docker

I checked the status again and get this:

service docker status
 * Docker is not running

Results of docker version

Client: Docker Engine - Community
 Version:           20.10.7
 API version:       1.41
 Go version:        go1.13.15
 Git commit:        f0df350
 Built:             Wed Jun  2 11:56:40 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Any ideas?