To build an alpine linux docker image with sqlite.
- Create a directory.
- In the directory above create a Dockerfile.
- Add the desired commands in the Dockerfile.
Following are the commands in the Dockerfile.
FROM alpine:3.12
RUN apk update && apk upgrade
RUN apk add --no-cache sqlite~=3.32.1-r0
Pull in the alpine linux image specifically version 3.12 then update and upgrade apk (a package manager for the Alpine distro) it's used to install additional software.
Lastly use apk to install sqlite note the semver tilde ranges i.e ~= which means the only versions of sqlite we want installed are equal to or greater than 3.32.1-r0 and less than 3.4.0
Finally build an image with the following command.
docker build -t your_new_image_name /path/to/the/Dockerfile
e.g. my Dockerfile is in the directory foo hence after I cd into foo I run the following command.
docker build -t my_alpine_linux_with_sqlite .
Then list your docker images with the command:-
docker images
You should see your_new_image_name among the list.
Then you can run a container off of your new image and sh into it (i.e. get into the container's shell) with
docker container run -ti your_new_image_name /bin/sh
In my case I ran
docker container run -ti my_alpine_linux_with_sqlite /bin/sh
Finally confirm sqlite is indeed installed by typing
sqlite3
and pressing enter. You'll see a sqlite prompt i.e.
sqlite>
And that is it congratulations you have installed sqlite.
Press Ctrl + D
to quit sqlite then exit
to exit your container's shell (in this case sh) and return back to your regular terminal (i.e. the host machine's shell).
Thank you for the post. It was very helpful for me to use.