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
    CSS @supports

    Feature detection via JavaScript is a client side best practice and for all the right reasons, but unfortunately that same functionality hasn't been available within CSS.  What we end up doing is repeating the same properties multiple times with each browser prefix.  Yuck.  Another thing we...

  • By
    Responsive and Infinitely Scalable JS Animations

    Back in late 2012 it was not easy to find open source projects using requestAnimationFrame() - this is the hook that allows Javascript code to synchronize with a web browser's native paint loop. Animations using this method can run at 60 fps and deliver fantastic...

Incredible Demos

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!