Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

279
Views
How to add "-v /var/run/docker.sock:/var/run/docker.sock" when running container from kubernetes deployment yaml

I'm setting up a kubernetes deployment with an image that will execute docker commands (docker ps etc.).

My yaml looks as the following:

kind: Deployment
apiVersion: apps/v1
metadata:
  name: discovery
  namespace: kube-system
  labels:
    discovery-app: kubernetes-discovery
spec:
  selector:
    matchLabels:
      discovery-app: kubernetes-discovery
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        discovery-app: kubernetes-discovery
    spec:
      containers:
      - image: docker:dind
        name: discover
        ports:
        - containerPort: 8080
          name: my-awesome-port
      imagePullSecrets:
        - name: regcred3
      volumes:
      - name: some-volume
        emptyDir: {}
      serviceAccountName: kubernetes-discovery

Normally I will run a docker container as following:

docker run -v /var/run/docker.sock:/var/run/docker.sock docker:dind

Now, kubernetes yaml supports commands and args but for some reason does not support options.

What is the right thing to do?

Perhaps I should configure a volume, but then, is it volumeMount or just a volume?

I am new with kubernetes so it is important for me to do it the right way.

Thank you

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

You want to add the volume to the container.

spec:
  containers:
  - name: discover
    image: docker:dind
    volumeMounts:
    - name: dockersock
      mountPath: "/var/run/docker.sock"
  volumes:
  - name: dockersock
    hostPath:
      path: /var/run/docker.sock  
over 4 years ago · Santiago Trujillo Report

0

It seems like a bad idea to interact directly with containers on any nodes in Kubernetes. The whole point of Kubernetes is to orchestrate. If you add containers outside of the Pod construct, then Kubernetes will not be aware the processes running on the nodes. This will affect resource allocation.

It also needs to be said that directly working with containers bypasses security.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!