Before be sure you properly upgraded to containers 0.3.0. Clean the old installation with sudo uninstall-container.sh -k
and then install the new version. Then start containers service container system start
. Check if it downloaded the latest vminit image. container i ls
If not then try sudo uninstall-container.sh -d
that deletes everything including the user data.
Setting the conainer subnet seems to be only necessary for macOS 15. Lookup the subnet of the bridge network with ifconfig
. Look for the bridge, e.g.
bridge100: flags=8a63<UP,BROADCAST,SMART,RUNNING,ALLMULTI,SIMPLEX,MULTICAST> mtu 1500
options=63<RXCSUM,TXCSUM,TSO4,TSO6>
ether be:d0:74:63:61:64
inet 192.168.206.1 netmask 0xffffff00 broadcast 192.168.206.255
Then set your container subnet to match the bridge network:
defaults write com.apple.container.defaults network.subnet 192.168.206.1/24
Set a local domain, I'm using home: defaults write com.apple.container.defaults dns.domain "home"
If you named the container, you can now just use {container name}.home to connect to it.
container run -d --name postgres -e POSTGRES_PASSWORD=postgres --rm --mount source=${HOME}/work/data/postgres,target=/var/lib/postgresql postgres:latest
Now you can do psql -h postgres.home -U postgres
You can install postgres clients with brew install libpq; brew link --force libpq
If you really need forwarding ports to localhost, it will also work now. Now you can try the example from the docs.
container run -d --rm -p 127.0.0.1:8080:8000 python:slim python3 -m http.server --bind 0.0.0.0 8000
Wait until the container is up then curl http:localhost:8080
to verify