├── .gitignore ├── .travis.yml ├── Dockerfile ├── readme.md └── test └── bash-it.bats /.gitignore: -------------------------------------------------------------------------------- 1 | # Developer: Maik Ellerbrock 2 | # 3 | # GitHub: https://github.com/ellerbrock 4 | # Twitter: https://twitter.com/frapsoft 5 | 6 | build.sh 7 | 8 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # Developer: 2 | # --------- 3 | # Name: Maik Ellerbrock 4 | # GitHub: https://github.com/ellerbrock 5 | # Twitter: https://twitter.com/frapsoft 6 | # Docker: https://hub.docker.com/u/ellerbrock 7 | # Quay: https://quay.io/user/ellerbrock 8 | # 9 | # Description: 10 | # ----------- 11 | # Travis Test for our Docker Container 12 | # - check if the docker build works 13 | # - run certain tests with bats 14 | 15 | language: bash 16 | 17 | sudo: required 18 | 19 | services: 20 | - docker 21 | 22 | before_install: 23 | - docker build --force-rm --no-cache -t ellerbrock/bash-it . 24 | - sudo add-apt-repository ppa:duggan/bats --yes 25 | - sudo apt-get update -qq 26 | - sudo apt-get install -qq bats 27 | 28 | script: 29 | - bats test/bash-it.bats 30 | 31 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # Developer: 2 | # --------- 3 | # Name: Maik Ellerbrock 4 | # 5 | # GitHub: https://github.com/ellerbrock 6 | # Twitter: https://twitter.com/frapsoft 7 | # Docker: https://hub.docker.com/u/ellerbrock 8 | # Quay: https://quay.io/user/ellerbrock 9 | # 10 | # Description: 11 | # ----------- 12 | # Bash Shell v.5 with Bash-it, bats, bash-completion 13 | 14 | FROM bash:5 15 | 16 | MAINTAINER Maik Ellerbrock 17 | 18 | ENV VERSION 0.1.0 19 | 20 | # Optional Configuration Parameter 21 | ARG SYSTEM_TZ 22 | 23 | # Default Settings (for optional Parameter) 24 | ENV SYSTEM_TZ ${SYSTEM_TZ:-Europe/Berlin} 25 | 26 | ENV SERVICE_USER bashit 27 | ENV SERVICE_HOME /home/${SERVICE_USER} 28 | 29 | RUN \ 30 | adduser -h ${SERVICE_HOME} -s /bin/bash -u 1000 -D ${SERVICE_USER} && \ 31 | apk add --no-cache \ 32 | bash-completion \ 33 | dumb-init \ 34 | git \ 35 | tzdata && \ 36 | cp /usr/share/zoneinfo/${SYSTEM_TZ} /etc/localtime && \ 37 | echo "${SYSTEM_TZ}" > /etc/TZ && \ 38 | git clone --depth 1 https://github.com/Bash-it/bash-it.git /tmp/bash_it && \ 39 | cp -R /tmp/bash_it /root/.bash_it && \ 40 | cp -R /tmp/bash_it ${SERVICE_HOME}/.bash_it && \ 41 | /root/.bash_it/install.sh --silent && \ 42 | echo -e "\n# Load bash-completion\n[ -f /usr/share/bash-completion/bash_completion ] && source /usr/share/bash-completion/bash_completion" >> /root/.bashrc && \ 43 | git clone --depth 1 https://github.com/sstephenson/bats.git /tmp/bats && \ 44 | /tmp/bats/install.sh /usr/local && \ 45 | cp -R ${SERVICE_HOME}/.bash_it /root && \ 46 | chown -R ${SERVICE_USER}:${SERVICE_USER} ${SERVICE_HOME} && \ 47 | sed -i -e "s/bin\/ash/bin\/bash/" /etc/passwd && \ 48 | apk del git tzdata && \ 49 | rm -rf /tmp/{.}* /tmp/* 50 | 51 | USER ${SERVICE_USER} 52 | 53 | WORKDIR ${SERVICE_HOME} 54 | 55 | RUN \ 56 | ${SERVICE_HOME}/.bash_it/install.sh --silent && \ 57 | echo -e "\n# Load bash-completion\n[ -f /usr/share/bash-completion/bash_completion ] && source /usr/share/bash-completion/bash_completion" >> ${SERVICE_HOME}/.bashrc 58 | 59 | ENTRYPOINT [ "/usr/bin/dumb-init", "bash" ] 60 | 61 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | ![docker](https://github.frapsoft.com/bashit/Bash-it_400px_transparent.png) 2 | 3 | # bash-it-docker 4 | 5 | _Bash Shell v.5 with [Bash-it](https://github.com/Bash-it/bash-it), [bats](https://github.com/sstephenson/bats) and [bash-completion](https://github.com/scop/bash-completion) based on [Alpine Linux](https://alpinelinux.org/) as unprivileged User_ 6 | 7 | [![Build Status](https://travis-ci.org/Bash-it/bash-it-docker.svg?branch=master)](https://travis-ci.org/Bash-it/bash-it-docker) [![Docker Automated Build](https://img.shields.io/docker/automated/ellerbrock/bash-it.svg)](https://hub.docker.com/r/ellerbrock/bash-it/) [![Docker Pulls](https://img.shields.io/docker/pulls/ellerbrock/bash-it.svg)](https://hub.docker.com/r/ellerbrock/bash-it/) [![Quay Status](https://quay.io/repository/ellerbrock/bash-it/status)](https://quay.io/repository/ellerbrock/bash-it) [![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg)](https://github.com/ellerbrock/open-source-badges/) [![Gitter Chat](https://badges.gitter.im/frapsoft/frapsoft.svg)](https://gitter.im/Bash-it/bash-it/) 8 | 9 | - Docker: [bash-it](https://hub.docker.com/r/ellerbrock/bash-it/) 10 | - Quay: [bash-it](https://quay.io/repository/ellerbrock/bash-it/) 11 | 12 | ## Info 13 | 14 | _Consider this Repository as Work in Progress._ 15 | 16 | You can find Documentation how to use and setup Bash-it in the [Main Repository](https://github.com/Bash-it/bash-it). 17 | Please open only issues related to Docker in this Repository. 18 | 19 | ## Installation 20 | 21 | `docker pull ellerbrock/bash-it` 22 | 23 | ## About the Container 24 | 25 | As Base Image i use [Alpine Linux](https://alpinelinux.org/) which is lightweight Distribution with a small surface area for security concerns, but with enough functionality for development and interactive debugging. 26 | 27 | To prevent zombie reaping processes i run [dumb-init](https://github.com/Yelp/dumb-init) as PID 1 which forwards signals to all processes running in the container. 28 | 29 | ## Example Usage 30 | 31 | **Start a interactive Bash Shell (default)** 32 | 33 | `docker run -it ellerbrock/bash-it` 34 | 35 | **Use your local `~/.bashrc` settings inside the Container (:ro for read only)** 36 | 37 | `docker run -it -v ~/.bashrc:/home/bashit/.bashrc:ro ellerbrock/bash-it` 38 | 39 | **Map the current directory inside the Container** 40 | 41 | `docker run -it ${PWD}:/data ellerbrock/bash-it` 42 | 43 | **Map a [Docker Volume](https://docs.docker.com/engine/tutorials/dockervolumes/)** 44 | 45 | `docker run -it myVolName:/app ellerbrock/bash-it` 46 | 47 | **Copy Data between Volumes** 48 | 49 | ``` 50 | docker run -it \ 51 | -v import:/import \ 52 | -v export:/export \ 53 | ellerbrock/bash-it -c "cp -R /import/* /export" 54 | ``` 55 | 56 | **Backup a Volume to Disk** 57 | 58 | ``` 59 | docker run -it \ 60 | -v import:/import \ 61 | -v ${PWD}:/export \ 62 | ellerbrock/bash-it -c "tar -cvjf /export/backup.tar.bz2 /import/" 63 | ``` 64 | 65 | **Run a Command** 66 | 67 | `docker run -it ellerbrock/bash-it -c "ls -alF /"` 68 | 69 | **Run as root** 70 | 71 | `docker run -it -u root ellerbrock/bash-it` 72 | -------------------------------------------------------------------------------- /test/bash-it.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | # Developer: 4 | # --------- 5 | # Name: Maik Ellerbrock 6 | # 7 | # GitHub: https://github.com/ellerbrock 8 | # Twitter: https://twitter.com/frapsoft 9 | # Docker: https://hub.docker.com/u/ellerbrock 10 | # Quay: https://quay.io/user/ellerbrock 11 | # 12 | # Description: 13 | # ----------- 14 | # Simple test with bats 15 | 16 | @test "check if we can execute bash inside the container" { 17 | run docker run -it ellerbrock/bash-it --help 18 | [ "$status" -eq 0 ] 19 | } 20 | 21 | @test "check if bats is available" { 22 | run docker run -it ellerbrock/bash-it -c "[[ $(which bats) ]]" 23 | [ "$status" -eq 0 ] 24 | } 25 | 26 | @test "check if the bash-it folder exists" { 27 | run docker run -it ellerbrock/bash-it -c "[[ -d /home/bashit/.bash_it ]]" 28 | [ "$status" -eq 0 ] 29 | } 30 | 31 | @test "check if the bash-completion folder exists" { 32 | run docker run -it ellerbrock/bash-it -c "[[ -d /usr/share/bash-completion ]]" 33 | [ "$status" -eq 0 ] 34 | } 35 | 36 | @test "check if we run as an unprivileged user" { 37 | run docker run -it ellerbrock/bash-it -c "[[ ${UID} -ne 0 ]]" 38 | [ "$status" -eq 0 ] 39 | } 40 | 41 | @test "check that the current process is greater then pid 1" { 42 | run docker run -it ellerbrock/bash-it -c "[[ ${$} -gt 1 ]]" 43 | [ "$status" -eq 0 ] 44 | } 45 | 46 | --------------------------------------------------------------------------------