How to build your own Manjaro base image for Docker

Want to run Manjaro in a container, and want to create your own base image instead of the one I pushed to

It's surprisingly straightforward, and the process will work in exactly the same way for plain Arch.

Step 1: ensure Docker is running

systemctl start docker

Step 2: create your root filesystem

cd /path/to/somewhere/with/space
mkdir rootfs
sudo pacstrap -cdGM rootfs filesystem pacman

Step 3: customise files

sudo nano rootfs/etc/pacman-mirrors.conf
# etc

Step 4: import into Docker

sudo tar -C rootfs -c . | docker import - my-image-name

Step 5: set up pacman-key

docker run -it my-image-name /bin/bash
[root@containerid /] pacman-key --init
[root@containerid /] pacman-key --populate archlinux manjaro
[root@containerid /] history -c

Step 6: commit the changes

docker commit ${containerid} my-image-name

or to "commit" a single-layer image to save a little space:

docker export ${containerid} | docker import - my-image-name

You can tidy up with the usual methods, e.g. docker system prune.

Step 7: use the base image for your Dockerfile

FROM my-image-name

RUN pacman -Syu --noconfirm base-devel
RUN pacman -Scc --noconfirm


Step 8: celebrate your containerised Manjaro

and tell us what interesting things you use it for. :slight_smile:


Maybe add a list of required packages in the beginning? Also, if you install manjaro-tools instead of arch-install-scripts, you can use badestrap instead of pacstrap. They both do pretty much the same thing though, so it doesn't really matter...

Just strolling by on my hunt for ideas to setup a buildbot - and thought I remembered this post exactly

badestrap - I don't think I know about that one?

Do you mean basestrap?

Yes, a typing error there is.

Forum kindly sponsored by