Skip to content

y-hatano-github/scratch-bash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 

Repository files navigation

scratch-bash

This is note to myself on how to use bin/bash with scratch image.

  1. Check bin/bash dependencies

    $ ldd /bin/bash
            linux-vdso.so.1 (0x00007ffff87c1000)
            libtinfo.so.6 => /lib/x86_64-linux-gnu/libtinfo.so.6 (0x00007f37b09a9000)
            libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f37b0780000)
            /lib64/ld-linux-x86-64.so.2 (0x00007f37b0b44000)
    
  2. Copy bin/bash and dependent files to work directory.

    $ cp /lib/x86_64-linux-gnu/libtinfo.so.6 ./
    $ cp /lib/x86_64-linux-gnu/libc.so.6 ./
    $ cp /lib64/ld-linux-x86-64.so.2 ./
    $ cp /bin/bash ./
    
  3. Write a Dockerfile that copies /bin/bash and the dependency files to the container.

    FROM scratch
    COPY ./libtinfo.so.6 /lib/x86_64-linux-gnu/libtinfo.so.6
    COPY ./libc.so.6 /lib/x86_64-linux-gnu/libc.so.6
    COPY ./ld-linux-x86-64.so.2 /lib64/ld-linux-x86-64.so.2
    COPY ./bash /bin/bash
    CMD ["/bin/bash"]
    
  4. Build

    $ docker build -t scrach ./
    [+] Building 0.1s (8/8) FINISHED                                                                 docker:default
    => [internal] load build definition from Dockerfile                                                       0.0s
    => => transferring dockerfile: 254B                                                                       0.0s
    => [internal] load .dockerignore                                                                          0.0s
    => => transferring context: 2B                                                                            0.0s
    => [internal] load build context                                                                          0.0s
    => => transferring context: 4.06MB                                                                        0.0s
    => CACHED [1/4] COPY ./libtinfo.so.6 /lib/x86_64-linux-gnu/libtinfo.so.6                                  0.0s
    => CACHED [2/4] COPY ./libc.so.6 /lib/x86_64-linux-gnu/libc.so.6                                          0.0s
    => CACHED [3/4] COPY ./ld-linux-x86-64.so.2 /lib64/ld-linux-x86-64.so.2                                   0.0s
    => CACHED [4/4] COPY ./bash /bin/bash                                                                     0.0s
    => exporting to image                                                                                     0.0s
    => => exporting layers                                                                                    0.0s
    => => writing image sha256:80733217972cae75a51053bc6e20269ca75df7357f3473055b51dd1d0b621fc3               0.0s
    => => naming to docker.io/library/scrach
    
  5. Run

    $ docker run -it scrach
    bash-5.1# echo *
    bin dev etc lib lib64 proc sys
    bash-5.1#
    

About

This is a note to myself on how to use /bin/bash with scratch image

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published