Docker for Mac uses a lot of resources, especially in terms of CPU and disk space. Connecting to a remote instance of Docker means my MacbookPro can put those resources towards my IDE.
A server with SSH access.
docker
and docker-machine
on your computer.
I created a role to automate the process; It's setting up a user to do the bootstrapping, opening up port 2376
on the server and then calling docker-machine
on your computer to bootstrap docker.
---- name: user (dockerbootstrap)user:name: dockerbootstrapcomment: Docker Bootstrappassword: ...group: sudoshell: /bin/bash- name: authorized key (dockerbootstrap)authorized_key:user: dockerbootstrapstate: presentkey: "{{ lookup('file', lookup('env','HOME') + '/.ssh/id_rsa.pub') }}"- name: passwordless sudo (dockerbootstrap)lineinfile:path: /etc/sudoersline: dockerbootstrap ALL=(ALL) NOPASSWD:ALL- name: allow 2376 (docker)tags: ["networking"]ufw:rule: allowport: "2376"proto: tcp- name: create docker machinetags: ["local"]become: nolocal_action:module: commandargv:- docker-machine- create- --driver- generic- --generic-ip-address- "{{ inventory_hostname }}"- --generic-ssh-key- "{{ lookup('env','HOME') + '/.ssh/id_rsa' }}"- --generic-ssh-user- dockerbootstrap- docker- name: remove user (dockerbootstrap)user:name: dockerbootstrapstate: absentremove: yes- name: remove passwordless sudo (dockerbootstrap)lineinfile:path: /etc/sudoersline: dockerbootstrap ALL=(ALL) NOPASSWD:ALLstate: absent
Then on your computer it's a case of running
eval $(docker-machine env docker)
and with any luck docker version
will give you:
❯ docker versionClient: Docker Engine - CommunityVersion: 19.03.8API version: 1.40Go version: go1.14Git commit: afacb8bBuilt: Thu Mar 12 02:45:41 2020OS/Arch: darwin/amd64Experimental: falseServer: Docker Engine - CommunityEngine:Version: 19.03.8API version: 1.40 (minimum version 1.12)Go version: go1.12.17Git commit: afacb8b7f0Built: Wed Mar 11 01:24:19 2020OS/Arch: linux/amd64Experimental: falsecontainerd:Version: 1.2.13GitCommit: 7ad184331fa3e55e52b890ea95e65ba581ae3429runc:Version: 1.0.0-rc10GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dddocker-init:Version: 0.18.0GitCommit: fec3683
Commands I use a fair amount
Reclaim space
❯ docker system prune -a --volumesWARNING! This will remove:- all stopped containers- all networks not used by at least one container- all images without at least one container associated to them- all build cacheAre you sure you want to continue? [y/N]
Flag | Description |
-a | Remove all unused images not just dangling ones |
--volumes | Prune volumes |