dracoblue.net

Docker CLI with Apple Container

Currently, I am running Rancher Desktop for Docker CLI needs locally. But I've found a viable solution I wanted to give a try.

It's called container and it is released by Apple at https://github.com/apple/container for Apple Silicon Mac devices.

As prerequisites for my setup, I use https://brew.sh/ as my package manager on macOS.

I got the latest release via:

brew install container

Then launch the background services like this:

$ brew services start container

Now you will be able to run:

$ container run hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

Success.

The nice part is, you can install a DNS setup (e.g., for the .test TLD) like this:

$ sudo container system dns create test
$ container system property set dns.domain test

This will make all your containers available like this.

Running Nginx is as easy as:

$ container run --rm --name nginx nginx:alpine

and you can access it via http://nginx.test. Wow! :)

If you need Docker compatibility (and if you are very brave!), give https://github.com/socktainer/socktainer a try.

Install it via:

$ brew tap socktainer/tap
$ brew install socktainer

You will need the Docker CLI and Docker Compose like this:

$ brew install docker
$ brew install docker-compose

(It does not ship with the Docker engine!)

Now you can run Socktainer like this:

$ socktainer
[FolderWatcher] Started watching /Users/jan/Library/Application Support/com.apple.container
[ NOTICE ] Server started on http+unix: /Users/jan/.socktainer/container.sock

or install it via:

$ brew services restart socktainer/tap/socktainer

as a service. Make sure that socktainer is the same version as your apple container. 0.10 of container will NOT work out of the box with socktainer 0.9. I failed this way for you.

$ container --version
container CLI version 0.9.0 (build: release, commit: 3e49dce)
$ socktainer --version
socktainer: v0.9.0 (git commit: 6a710bf)

In another shell (or in your .bashrc), do:

$ export DOCKER_HOST=unix://$HOME/.socktainer/container.sock

and you can run:

$ docker run --rm -it hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

Have fun!

Give something back

Were my blog posts useful to you? If you want to give back, support one of these charities, too!

Report hate in social media Campact e.V. With our technology and your help, we protect the oceans from plastic waste. Gesellschaft fur Freiheitsrechte e. V. The civil eye in the mediterranean

Recent Dev-Articles

Read recently

Recent Files

About