Running containers on a Mac

Docker Desktop can be used for free as part of a Docker Personal subscription for: small companies (fewer than 250 employees AND less than $10 million in annual revenue), personal use, education, and non-commercial open source projects.
  1. Podman
  2. Vagrant with virtual box
brew install podman
podman info
podman machine init
podman machine start
brew install python@3.10pip3 install podman-compose
# Install VirtualBoxbrew install --cask virtualboxbrew install --cask virtualbox-extension-pack# Install Vagrant and the vbguest plugin to manage VirtualBox Guest Additions on the VMbrew install vagrantvagrant plugin install vagrant-vbguest# Install Docker CLIbrew install dockerbrew install docker-compose
mkdir vagrant-docker-engine
cd vagrant-docker-engineecho \"Vagrant.configure('2') do |config| = 'ubuntu/focal64'config.vm.hostname = 'docker.local'config.vm.synced_folder "/Users/irfan/docker_data", "/vagrant", type: "rsync" 'private_network', ip: '' 'forwarded_port', guest: 2375, host: 2375, id: 'dockerd'config.vm.provider 'virtualbox' do |vb| = 'ubuntu-docker'vb.memory = '2048'vb.cpus = '2'endconfig.vm.provision 'shell', path: ''# Configuration for Port Forwarding# Uncomment or add new ones here as 'forwarded_port', guest: 6379, host: 6379, id: 'redis-server' 'forwarded_port', guest: 5432, host: 5432, id: 'postgres-server' 'forwarded_port', guest: 3306, host: 3306, id: 'mysql-server'end" | tee Vagrantfile > /dev/nullecho \"# Install Dockerapt-get remove docker docker-engine containerd runcapt-get updateapt-get install -y apt-transport-https ca-certificates curl gnupg lsb-release net-tools software-properties-commoncurl -fsSL | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpgecho 'deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] focal stable' | tee /etc/apt/sources.list.d/docker.list > /dev/nullapt-get updateapt-get install -y docker-ce docker-ce-cli Configure Docker to listen on a TCP socketmkdir /etc/systemd/system/docker.service.decho \\'[Service]ExecStart=ExecStart=/usr/bin/dockerd --containerd=/run/containerd/containerd.sock' | tee /etc/systemd/system/docker.service.d/docker.conf > /dev/nullecho \\'{\"hosts\": [\"fd://\", \"tcp://\"]}' | tee /etc/docker/daemon.json > /dev/nullsystemctl daemon-reloadsystemctl restart docker.service" | tee > /dev/nullchmod +x
vagrant up
The IP address configured for the host-only network is not within the
allowed ranges. Please update the address used to be within the allowed
ranges and run the command again. Address:
Ranges: 192.168.xx.0/21
# Save IP to a hostname
echo " docker.local" | sudo tee -a /etc/hosts > /dev/null

# Tell Docker CLI to talk to the VM
export DOCKER_HOST=tcp://docker.local:2375
# Uncomment or add new ones here as 'forwarded_port', guest: 6379, host: 6379, id: 'redis-server'

Vagrant Cheatsheet

vagrant suspend - stop the VM for saving system resources. This does not delete any data. Just run vagrant up to spin up the VM.

  1. Press ⌘ , to open the IDE settings and select Build, Execution, Deployment | Docker.
  2. Click + to add a Docker configuration.
  3. Select TCP socket and specify the Docker API service URL in Engine API URL: tcp://localhost:2375.
  1. If everything is correct, you should see Connection successful at the bottom of the page. Else check if the VM is running or suspended.
  2. Double-click the configured Docker connection in the Services tool window (View | Tool Windows | Services or ⌘ 8).



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Irfan Ali Shaik

Irfan Ali Shaik

Software engineer, technology enthusiast