I'm working on Centos7. I have a Docker container which is running Jenkins. In that Jenkins-container I have to build and run other Docker containers. But Jenkins doesn't know docker. I'm able to execute a shell and install docker inside the container. But isn't it possible to let the container use my docker-engine on the host? How can I use it?
What is the best option to install Docker inside a Jenkins-(docker)-container?
Generally, a container-in-container setup involves linking
/var/run/docker.sock
anddocker
itself.For example, in this thread:
This is not exactly your case, since you don't need to run Jenkins itself in a "cic" (container in container").
But that illustrates how you would run any container in a container, with docker available in it.
Make sure the user in that container is part of the docker group (if you don't want to use root), as in this
jenkins/setup-docker-and-start-jenkins.sh
scriptNote that this setup uses
tini
to launch Jenkins (as I described in "Jenkins does not run automatically after install in Docker container")Again, those scripts are for using Jenkins in "cic".
In your case, you can use those scripts for the containers that your Jenkins will have to run.
Using the official Jenkins docker image:
Then to verify everything is working:
docker version
as contentIf you run into the following error on CentOS 7:
then start the container with: