Code-server: Docker In Docker for code-server

Created on 11 Mar 2019  路  18Comments  路  Source: cdr/code-server

I've been trying to fiddle with the Dockerfile of code-server to add support for Docker in Docker but without success, I tried numerous ubuntu images but then code-server will have problem running:

those are the ones I tested:
https://hub.docker.com/r/billyteves/ubuntu-dind
https://hub.docker.com/r/jazzypro/ubuntu-dind
https://hub.docker.com/r/ciiichy/ubuntu-dind-git
https://hub.docker.com/r/ceregousa/dind
https://hub.docker.com/r/huksley/ubuntu-dind/dockerfile

most of the times i'm getting

{"data":"Error: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.22' not found (required by /root/project/.local/share/code-server/dependencies/spdlog.node)\n    at Object.Module._extensions..node (module.js:682:18)\n    at Module.load (module.js:566:32)\n    at tryModuleLoad (module.js:506:12)\n    at Function.Module._load (module.js:498:3)\n    at Module.require (module.js:597:17)\n    at Module.patchedRequire [as require] (eval at exports.requireModule (/usr/local/bin/code-server:468:27625), <anonymous>:6615:46)\n    at require (internal/module.js:11:18)\n    at f (/usr/local/bin/code-server:2281:1092)\n    at u (/usr/local/bin/code-server:2281:1344)\n    at c (/usr/local/bin/code-server:2281:2750)\n    at b.require (/usr/local/bin/code-server:2281:3346)\n    at Object../lib/vscode/node_modules/spdlog/index.js (eval at exports.requireModule (/usr/local/bin/code-server:468:27625), <anonymous>:28679:16)\n    at __webpack_require__ (eval at exports.requireModule (/usr/local/bin/code-server:468:27625), <anonymous>:26:30)\n    at Object.createSpdLogService (eval at exports.requireModule (/usr/local/bin/code-server:468:27625), <anonymous>:157268:29)\n    at main (eval at exports.requireModule (/usr/local/bin/code-server:468:27625), <anonymous>:77357:92)\n    at eval (eval at exports.requireModule (/usr/local/bin/code-server:468:27625), <anonymous>:77449:13)\n    at Generator.next (<anonymous>)\n    at fulfilled (eval at exports.requireModule (/usr/local/bin/code-server:468:27625), <anonymous>:77333:58)\n    at <anonymous>\n    at process._tickCallback (internal/process/next_tick.js:189:7)\n"}
code-server_1     | INFO  Retrying shared process in 8s {"error":"Exited with null"}

when code-server is trying to boot up, do you have any idea to do what i'm trying to achieve ?

question

All 18 comments

See #190

To be honest i didn't really understood how to apply #190 to my problem ?

Hey @Rakiah, here's an idea from me:

  • use the DIND image from PWD (they have a Ubuntu version)
  • install the required dependencies (net-tools)
  • Pull code-server from releases.

OK I see that #190 would sove it using Kubernetes
sadly we don't use kubernetes at work and I dont have a PHD in kubernetology :(

I've been trying to find an image called DIND under PWD in hub.docker.com but didn't find anything, can you provide a link for that please @sr229
thanks for your help

EDIT:

I think I found the DIND image you're speaking about:
https://hub.docker.com/r/franela/dind/tags

I'll check and update my results

seems like 18.09 ubuntu is not enough neither:
ERROR SHARED stderr {"data":"Error: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.22' not found (required by /root/project/.local/share/code-server/dependencies/spdlog.node
got the same error

You could also use the docker:dind as a side-car.
Install docker normally in the code-server image, create a docker:dind container and link it to the code-server-container, you should be able to use docker in code-server.

Update, tested works:
image

Stivik, may you provide steps for this ?
How would I link the docker:dind container to code-server ?

Stivik, may you provide steps for this ?
How would I link the docker:dind container to code-server ?

https://docs.docker.com/network/links/

Ok that's also what I tought but I may misunderstood the points of docker link because I didnt think that would work, will try !

@arukaen I don't recommend suggesting deprecated Docker APIs and CLI commands to solve a solution.

@Rakiah While this might be a temporary solution, keep in mind Docker links are deprecated.

Docker link itself was not enough:
i've created a network between the two container, installed docker-cli in the code-server container and exported the docker host like this in the code-server container:
export DOCKER_HOST="tcp://dind:2375"
(dind is the docker in docker container)

this seems to work for my needs

Seems like this might not be a docker-in-docker issue and a GLIBC issue. We lowered the GLIBC requirement a while back, could you try again?

I found my answer during this thread and do not have the problem anymore thank you @kylecarbs we can close this

CC @kylecarbs or @coadler to close the issue as per request by the author

In case anyone is looking to do this with kubernetes, here is my deployment I'm using that has this working as far as I've tested:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: code-server
  namespace: default
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: code-server
    spec:
      initContainers:
      - name: copy-docker-binary
        image: docker:stable-dind
        command: ['sh', '-c', 'cp /usr/local/bin/docker /code-server-bin/']
        volumeMounts:
        - name: code-server-usr-local-bin
          mountPath: /code-server-bin
      containers:
      - name: code-server
        image: linuxserver/code-server
        imagePullPolicy: Always
        ports:
        - containerPort: 8443
          name: https
        envFrom:
        - configMapRef:
            name: code-server
        - secretRef:
            name: code-server
        volumeMounts:
        - name: config
          mountPath: /config
          readOnly: false
        - name: code-server-usr-local-bin
          mountPath: /usr/local/bin
      - name: dind-daemon
        image: docker:stable-dind
        env:
        - name: DOCKER_TLS_CERTDIR
          value: ""
        resources:
          requests:
            cpu: 20m
            memory: 512Mi
        securityContext:
            privileged: true
        volumeMounts:
          - name: docker-graph-storage
            mountPath: /var/lib/docker
      volumes:
      - name: config
        persistentVolumeClaim:
          claimName: code-server-config
      - name: docker-graph-storage
        emptyDir: {}
      - name: code-server-usr-local-bin
        emptyDir: {}

Let me know if you need my other resources for this, but I believe everything for this issue is covered in this deployment.

Would appreciate if you can do a documentation PR for this as well since people might want to run Docker development in Docker-based code-server.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Arsaev picture Arsaev  路  3Comments

avelino picture avelino  路  3Comments

korzq picture korzq  路  3Comments

balazssoltesz picture balazssoltesz  路  3Comments

sa7mon picture sa7mon  路  3Comments