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:
- 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
- then from
- changed the copy destination from container from
/binso that I would successfully run the
ignitefunction from that
…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…
- placed the entrypoint in the container at
- then I’ve changed the
#!/usr/bin/env ashbecause we’re on Alpine Linux after all!
- ran the entrypoint with
- it was then when I saw the message:
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.