I thought I understood Docker until I saw the BusyBox docker image

后端 未结 3 1144
我寻月下人不归
我寻月下人不归 2020-12-23 19:52

I thought I understood Docker. I understood it as a way to package up software with lots of dependencies..to basically create a little world where absolutely everything is t

相关标签:
3条回答
  • 2020-12-23 20:09

    A Busybox docker image is useful if one is building a container for which busybox can fulfill its dependency chain without needing a full Linux distro.

    Often, an embedded appliance can consist of nothing but a statically-linked copy of busybox, an init script that mounts procfs, sysfs, &c. with busybox-provided tools, and then the actual application being invoked. With docker setting up the filesystem namespace, even that init script isn't necessarily needed.

    0 讨论(0)
  • 2020-12-23 20:17

    In addition to being a convenient base to use for other docker images. Busybox also makes a very convenient initContainer for kubernetes: https://kubernetes.io/docs/concepts/workloads/pods/init-containers/

    Say you need something to happen that sets up the pod filesystem before your real container starts running then busybox is great at this..

    As a concrete example the official redis image doesn't run redis as root and so it cannot access the filesystem. If you were running redis with disk backup (in appendonly mode for example) you would need to open up that disk permission for it.

    a valid (though probably hacky) initContainer for a statefulSet of redis might looks something like so:

          initContainers:
          - name: redis-data-permission-fix
            image: busybox
            command: ["/bin/chmod", "-R", "777", "/opt/data/redis"]
            volumeMounts:
            - name: data
              mountPath: /opt/data/redis
    
    0 讨论(0)
  • 2020-12-23 20:26

    But I don't understand at all why this image exists, which makes me think that I don't actually understand why Docker exists. What is the point of a BusyBox docker image?

    I just started using BusyBox with docker, but so far it has been convenient to use with the --rm command to create unsaved instances with common built in utilities like ping, and yeah just ping so far :/

    docker container run --rm -it --network [network_name] busybox
    

    and then all those utilities in BusyBox are available on that docker custom network and instantly destroyed when you exit the BusyBox CLI

    0 讨论(0)
提交回复
热议问题