Bash Docker Image
Bash是GNU计划开发的Bourne Again Shell(即“重生的Bourne Shell”),作为Unix及类Unix系统中的命令行解释器,它不仅替代了传统的Bourne Shell(sh),还通过增强命令行编辑、脚本编程、环境变量管理等功能,成为众多Linux发行版和macOS的默认shell,广泛应用于系统管理、自动化任务和软件开发等领域,是用户与操作系统交互的重要工具。
Quick reference
-
Maintained by:
https://github.com/tianon/docker-bash, https://github.com/docker-library/official-images/pull/2217#issue-*** -
Where to get help:
https://dockr.ly/comm-slack, Server Fault, https://unix.stackexchange.com/help/on-topic, or https://stackoverflow.com/help/on-topic
Supported tags and respective Dockerfile links
-
https://github.com/tianon/docker-bash/blob/b277470669f3a8e7533f6acc79643c80f2dcbcca/devel/Dockerfile
-
https://github.com/tianon/docker-bash/blob/1bb2a0ceb6051372ffeb490e96aa7b0ba***b/5.3/Dockerfile
-
https://github.com/tianon/docker-bash/blob/9fc164bd1a8e4bfe16c517623ce935dc821bbb08/5.2/Dockerfile
-
https://github.com/tianon/docker-bash/blob/b***d03c9509a2faaeacbb710ee824c586843/5.1/Dockerfile
-
https://github.com/tianon/docker-bash/blob/5f58d08f8ee4a558b8302ef22352af99d4beedfd/5.0/Dockerfile
-
https://github.com/tianon/docker-bash/blob/099d6114cbdb9b016fb8c4beb653187df002f66f/4.4/Dockerfile
-
https://github.com/tianon/docker-bash/blob/099d6114cbdb9b016fb8c4beb653187df002f66f/4.3/Dockerfile
-
https://github.com/tianon/docker-bash/blob/8556e37dc74a044cfd6e8255acfd116a5bdb8588/4.2/Dockerfile
-
https://github.com/tianon/docker-bash/blob/099d6114cbdb9b016fb8c4beb653187df002f66f/4.1/Dockerfile
-
https://github.com/tianon/docker-bash/blob/77e400b36b508fd5927dafa9d2905ddc8935bf6e/4.0/Dockerfile
-
https://github.com/tianon/docker-bash/blob/099d6114cbdb9b016fb8c4beb653187df002f66f/3.2/Dockerfile
-
https://github.com/tianon/docker-bash/blob/099d6114cbdb9b016fb8c4beb653187df002f66f/3.1/Dockerfile
-
https://github.com/tianon/docker-bash/blob/5ffa8349006e790fe3534d0a6c3100fd6d725407/3.0/Dockerfile
Quick reference (cont.)
-
Where to file issues:
https://github.com/tianon/docker-bash/issues?q=is:issue+is:pr -
Supported architectures: (https://github.com/docker-library/official-images#architectures-other-than-amd64)
https://hub.docker.com/r/amd64/bash/, https://hub.docker.com/r/arm32v6/bash/, https://hub.docker.com/r/arm32v7/bash/, https://hub.docker.com/r/arm64v8/bash/, https://hub.docker.com/r/i386/bash/, https://hub.docker.com/r/ppc64le/bash/, https://hub.docker.com/r/riscv64/bash/, https://hub.docker.com/r/s390x/bash/ -
Published image artifact details:
https://github.com/docker-library/repo-info/blob/master/repos/bash (https://github.com/docker-library/repo-info/commits/master/repos/bash)
(image metadata, transfer size, etc) -
Image updates:
https://github.com/docker-library/official-images/issues?q=label%3Alibrary%2Fbash
https://github.com/docker-library/official-images/blob/master/library/bash (https://github.com/docker-library/official-images/commits/master/library/bash) -
Source of this description:
https://github.com/docker-library/docs/tree/master/bash (https://github.com/docker-library/docs/commits/master/bash)
What is Bash?
Bash is the http://www.gnu.org/ Project's Bourne Again SHell, a complete implementation of the http://www.opengroup.org/onlinepubs/9699919799/nfindex.html with interactive command line editing, job control on architectures that support it, csh-like features such as history substitution and brace expansion, and a slew of other features.
https://tiswww.case.edu/php/chet/bash/bashtop.html
How to use this image
The primary use cases this image is targeting are testing new features of more recent Bash versions before your primary distribution updates packages and testing shell scripts against different Bash versions to ensure compatibility. There are likely other interesting use cases as well, but those are the primary two the image was initially created to solve!
Notes
There are a few main things that are important to note regarding this image:
-
Bash itself is installed at
/usr/local/bin/bash, not/bin/bash, so the recommended shebang is#!/usr/bin/env bash, not#!/bin/bash(or explicitly running your script viabash /.../script.shinstead of letting the shebang invoke Bash automatically). The image does not include/bin/bash, but if it is installed via the package manager included in the image, that package will install to/bin/bashand might cause confusion (although/usr/local/binis ahead of/binin$PATH, so as long as plainbashor/usr/bin/envare used consistently, the image-provided Bash will be preferred). -
Bash is the only thing included, so if your scripts rely on external tools (such as
jq, for example), those will need to be added manually (viaapk add --no-cache jq, for example).
Interactive shell
console$ docker run -it --rm bash:4.4 bash-4.4# which bash /usr/local/bin/bash bash-4.4# echo $BASH_VERSION 4.4.0(1)-release
Testing scripts via bind-mount
console$ docker run -it --rm -v /path/to/script.sh:/script.sh:ro bash:4.4 bash /script.sh ... $ docker run -it --rm -v /path/to/script.sh:/script.sh:ro bash:3.2 bash /script.sh ...
Testing scripts via Dockerfile
dockerfileFROM bash:4.4 COPY script.sh / CMD ["bash", "/script.sh"]
Then, build and run the Docker image:
console$ docker build -t my-bash-app . ... $ docker run -it --rm --name my-running-app my-bash-app ...
License
Bash is free software, distributed under the terms of the http://www.gnu.org/licenses/gpl.html.
As with all Docker images, these likely also contain other software which may be under other licenses (such as Bash, etc from the base distribution, along with any direct or indirect dependencies of the primary software being contained).
Some additional license information which was able to be auto-detected might be found in https://github.com/docker-library/repo-info/tree/master/repos/bash.
As for any pre-built image usage, it is the image user's responsibility to ensure that any use of this image complies with any relevant licenses for all software contained within.
镜像拉取方式
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。
DockerHub 原生拉取命令
用户好评
来自真实用户的反馈,见证轩辕镜像的优质服务