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
    Welcome to My New Office

    My first professional web development was at a small print shop where I sat in a windowless cubical all day. I suffered that boxed in environment for almost five years before I was able to find a remote job where I worked from home. The first...

  • By
    CSS 3D Folding Animation

    Google Plus provides loads of inspiration for front-end developers, especially when it comes to the CSS and JavaScript wonders they create. Last year I duplicated their incredible PhotoStack effect with both MooTools and pure CSS; this time I'm going to duplicate...

Incredible Demos

  • By
    Check All/None Checkboxes Using MooTools

    There's nothing worse than having to click every checkbox in a list. Why not allow users to click one item and every checkbox becomes checked? Here's how to do just that with MooTools 1.2. The XHTML Note the image with the ucuc ID -- that...

  • By
    MooTools ASCII Art

    I didn't realize that I truly was a nerd until I could admit to myself that ASCII art was better than the pieces Picasso, Monet, or Van Gogh could create.  ASCII art is unmatched in its beauty, simplicity, and ... OK, well, I'm being ridiculous;  ASCII...

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!