Giter Club home page Giter Club logo

docker-in-jenkins-in-docker's Introduction

docker-in-jenkins-in-docker

a.k.a. DinJinD

Foreword

Trying to build Docker images from your Jenkins which is itself in a Docker container and still seeing Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? message? A solution is here!

If you want a Jenkins Docker image in which you can build Docker images, it is a bit tricky:

  • To be able to run Docker commands in a Docker container, you need to use the wrapdocker script from DinD project and run your container with the --privileged flag.
  • Because you cannot directly run multiple services in a container, you have to use a tool (Supervisor here) which will manage and run both Jenkins and Docker services. The container will then run Supervisor, which will start Jenkins and Docker.

How-to

  • Build image:
docker build -t docker-in-jenkins-in-docker .
  • Run container:
docker run --privileged -it -p 8080:8080 docker-in-jenkins-in-docker
  • Open Jenkins at http://localhost:8080/

Pitfall with DNS

If you have a specific DNS configuration (like nameserver and search entries in /etc/resolv.conf configuration), you should forward this DNS configuration to the Docker daemon. To do this, you have to create and configure /etc/docker/daemon.json file and specify dns and dns-search options. For example, you can add these lines to your Dockerfile after the Docker installation:

RUN mkdir -p /etc/docker
RUN touch /etc/docker/daemon.json
RUN echo '{"dns":["8.8.8.8","a.b.c.d"],"dns-search":["search1.domain","search2.domain"]}' > /etc/docker/daemon.json

See also

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.