Skip to content

Instantly share code, notes, and snippets.

@afbjorklund
Last active September 30, 2025 16:37
Show Gist options
  • Select an option

  • Save afbjorklund/90868919eae14320f0a71a8baf929f97 to your computer and use it in GitHub Desktop.

Select an option

Save afbjorklund/90868919eae14320f0a71a8baf929f97 to your computer and use it in GitHub Desktop.
apple container with docker
FROM ubuntu
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates curl && rm -rf /var/lib/apt/lists/*
RUN curl -fsSL https://get.docker.com | sh
RUN apt-get update && apt-get install -y --no-install-recommends procps && rm -rf /var/lib/apt/lists/*
RUN ( echo "net.ipv6.conf.all.disable_ipv6=1"; echo "net.ipv6.conf.default.disable_ipv6=1" ) | tee /etc/sysctl.d/container.conf
RUN apt-get update && apt-get install -y --no-install-recommends iptables && rm -rf /var/lib/apt/lists/*
RUN update-alternatives --set iptables /usr/sbin/iptables-legacy && update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy
RUN apt-get update && apt-get install -y --no-install-recommends systemd && rm -rf /var/lib/apt/lists/*
ENTRYPOINT ["/lib/systemd/systemd"]
# https://systemd.io/CONTAINER_INTERFACE/
STOPSIGNAL SIGRTMIN+3
@afbjorklund
Copy link
Author

afbjorklund commented Sep 30, 2025

Now Apple Container supports systemd, and we can run the regular Ubuntu LTS and Docker Engine

Previous workaround: https://gist.github.com/afbjorklund/99ec0683c82f03e58c22b0d2753b9f50


build container image with buildkit
container build -t ubuntu-docker .

start container VM in the background
container=$(container run -d ubuntu-docker)

open a shell in the running container
container exec -it $container bash

docker version

Client: Docker Engine - Community
 Version:           28.4.0
 API version:       1.51
 Go version:        go1.24.7
 Git commit:        d8eb465
 Built:             Wed Sep  3 20:58:55 2025
 OS/Arch:           linux/arm64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          28.4.0
  API version:      1.51 (minimum version 1.24)
  Go version:       go1.24.7
  Git commit:       249d679
  Built:            Wed Sep  3 20:58:55 2025
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          1.7.27
  GitCommit:        05044ec0a9a75232cad458027ca83437aae3f4da
 runc:
  Version:          1.2.5
  GitCommit:        v1.2.5-0-g59923ef
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment