Home > DevOps, docker, docker-compose, Uncategorized > Node.js app with Docker on Alpine base image

Node.js app with Docker on Alpine base image

When Alpine Linux first appeared, I had to give it a go, so I downloaded the first Official Alpine linux docker image and tried it. Conclusion: it was complicated.

Complicated because by then I didn’t know the importance of Docker base image size. So, in order to fight with my greatest fear: the great Alpine Linux image, I decided a few days ago to create a Slack bot having Alpine Linux 3.3 as base image. You can check the progress on my GitHub repo

I started with a plan so, I’ve added issues that I had to complete in order to be on track.

Then I decided that I need a tool to make my job easier, so I’ve made a bash script with docker-compose commands like:

  • start
  • stop
  • remove images
  • restart containers
  • run container

Then I had to create an entrypoint so that I could add all build commands for the project.

This is where it all gone wild…

  • entrypoint was copied in container from current_dir to /sbin/entrypoint.sh
  • when trying to run the container with docker run --rm -ti IMAGE_ID /bin/ashit was throwing this error:
    • docker: Error response from daemon: Container command 'sbin/entrypoint.sh' not found or does not exist.

I decided it was time to go in the long journey of debugging… journey that took my frikkin’ weekend…

What I tried…and all failed

  • modified the name of the script from entrypoint.sh  to simply entrypoint
  • modified the shebang line from #!/bin/bash to #!/bin/ash
  • then from #!/bin/ash to #!/usr/bin/env bash
  • changed the copy destination from container from /sbin/ to /binso that I would successfully run the ignite function from that shell script…

…and then it hit me…after 12 hours

I checked out other Dockerfileswritten by experts, I thought I was doing it wrong…

Then I decided just to make a plain Dockerfilethat tries to run a simple shell script with ls -lsa && pwd commands…

the solution

So i’ve

  • placed the entrypoint in the container at /bin/entrypointand
  • then I’ve changed the shebangfrom #/usr/bin/env bashto #!/usr/bin/env ashbecause we’re on Alpine Linux after all!
  • ran the entrypoint with entrypoint ignite
  • it was then when I saw the message:
    • total 8
      4 drwxr-xr-x 2 root root 4096 May 8 15:44 .
      4 drwxr-xr-x 31 root root 4096 May 8 15:44 ..
      its working! EVRIKA!

That was the mistake that costed me the weekend.

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: