Fix Bash Error in Docker

By  on  

I really enjoy working with Docker because it gives me more insight into creating and maintaining your own environments, mostly from scratch.  I instantly gained a greater appreciation for Ops engineers, package creators, and other engineers who work on low level software.  I think what I'm trying to say is that I've made a whole bunch of mistakes and completed an insane amount of Google searches for help.

One of the more basic errors I've recently encountered was trying to run a bash script within the container, only to get the following error:  env: can't execute 'bash': No such file or directory.  I was under the impression that bash was always a given in Linux machines, but apparently not in alpine images.  The fix was adding the following to my Dockerfile file:

RUN apk update && apk add bash

Or if you're in the machine, just run:

apk update && apk add bash

That command installs bash and your bash scripts should then work!

Recent Features

  • By
    6 Things You Didn’t Know About Firefox OS

    Firefox OS is all over the tech news and for good reason:  Mozilla's finally given web developers the platform that they need to create apps the way they've been creating them for years -- with CSS, HTML, and JavaScript.  Firefox OS has been rapidly improving...

  • By
    Creating Scrolling Parallax Effects with CSS

    Introduction For quite a long time now websites with the so called "parallax" effect have been really popular. In case you have not heard of this effect, it basically includes different layers of images that are moving in different directions or with different speed. This leads to a...

Incredible Demos

  • By
    Custom Scrollbars in WebKit

    Before each of the browser vendors we like was providing unique CSS controls, Internet Explorer was setting the tone.  One such example is IE's early implementation of CSS filters. Internet Explorer was also the first browser that allowed developers to, for better or worse, customize...

  • By
    Fancy Navigation with MooTools JavaScript

    Navigation menus are traditionally boring, right? Most of the time the navigation menu consists of some imagery with a corresponding mouseover image. Where's the originality? I've created a fancy navigation menu that highlights navigation items and creates a chain effect. The XHTML Just some simple...

Discussion

  1. Hamish

    Alternatively, you can use ash instead of bash.

    Not sure what the differences are, but I would expect parity on most standard features.

  2. If the script is simple you can use the default /bin/sh shell.

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!