chore: fixed-size volumes hack for os x

This commit is contained in:
Michele Cereda
2025-01-30 00:07:20 +01:00
parent ce19e3b21c
commit 5c0f3c74bc
4 changed files with 38 additions and 0 deletions

View File

@@ -442,6 +442,7 @@ docker load …
- [How to list the content of a named volume in docker 1.9+?]
- [Difference between Expose and Ports in Docker Compose]
- [Unable to reach services behind VPN from docker container]
- [Improve docker volume performance on MacOS with a RAM disk]
<!--
Reference
@@ -472,5 +473,6 @@ docker load …
[docker buildx bake + gitlab ci matrix]: https://teymorian.medium.com/docker-buildx-bake-gitlab-ci-matrix-77edb6b9863f
[getting around docker's host network limitation on mac]: https://medium.com/@lailadahi/getting-around-dockers-host-network-limitation-on-mac-9e4e6bfee44b
[how to list the content of a named volume in docker 1.9+?]: https://stackoverflow.com/questions/34803466/how-to-list-the-content-of-a-named-volume-in-docker-1-9
[improve docker volume performance on macos with a ram disk]: https://thoughts.theden.sh/posts/docker-ramdisk-macos-benchmark/
[opencontainers image spec]: https://specs.opencontainers.org/image-spec/
[unable to reach services behind vpn from docker container]: https://github.com/docker/for-mac/issues/5322

View File

@@ -544,6 +544,7 @@ your Mac, or after your Mac begins to restart. Keep holding until the described
- [Network warrior: how to use macOS network utilities]
- [Remap Home and End Keys?]
- [trusktr's default keybindings]
- [Improve docker volume performance on MacOS with a RAM disk]
<!--
Reference
@@ -576,6 +577,7 @@ your Mac, or after your Mac begins to restart. Keep holding until the described
[command line access to the mac keychain]: https://blog.koehntopp.info/2017/01/26/command-line-access-to-the-mac-keychain.html
[how to clear dns cache in macos ventura & macos monterey]: https://osxdaily.com/2022/11/21/how-clear-dns-cache-macos-ventura-monterey/
[how to update xcode from command line]: https://stackoverflow.com/questions/34617452/how-to-update-xcode-from-command-line#34617930
[improve docker volume performance on macos with a ram disk]: https://thoughts.theden.sh/posts/docker-ramdisk-macos-benchmark/
[installing .pkg with terminal?]: https://apple.stackexchange.com/questions/72226/installing-pkg-with-terminal#394976
[launchctl man page]: https://www.unix.com/man-page/osx/1/launchctl
[list all network hardware from command line in mac os]: https://osxdaily.com/2014/09/03/list-all-network-hardware-from-the-command-line-in-os-x/

View File

@@ -1,5 +1,9 @@
#!/usr/bin/env sh
docker info
docker info -f 'json'
docker system info --format '{{range .Plugins.Volume}}{{println .}}{{end}}'
docker images -a
docker images --digests
@@ -27,3 +31,14 @@ docker inspect 'prometheus-1' # container
# Install compose directly from package
dnf install 'https://download.docker.com/linux/fedora/41/aarch64/stable/Packages/docker-compose-plugin-2.32.1-1.fc41.aarch64.rpm'
# Create non-standard volumes
docker volume create --driver 'flocker' -o 'size=20GB' 'my-named-volume'
docker volume create --driver 'local' --opt 'type=tmpfs' --opt 'device=tmpfs' --opt 'o=size=100m,uid=1000' 'foo'
docker volume create --driver 'local' --opt 'type=btrfs' --opt 'device=/dev/sda2'
docker volume create --driver 'convoy' --opt 'size=100m' 'test'
# Use temporary, size-limited volumes in Mac OS X
# The example uses a 2GB RAM disk
hdiutil attach -nomount 'ram://4194304' | xargs diskutil erasevolume HFS+ 'ramdisk' \
&& docker run --rm --name 'alpine' -v "/Volumes/ramdisk/:/ramdisk" -it 'alpine' sh

View File

@@ -54,3 +54,22 @@ then
curl -C- -o '/tmp/macports.pkg https://github.com/macports/macports-base/releases/download/v2.7.2/MacPorts-2.7.2-12-Monterey.pkg'
sudo installer -pkg '/tmp/macports.pkg' -target '/'
fi
# Get available system information data types
system_profiler -listDataTypes
# Show current sysinfo
system_profiler --json -detailLevel 'mini'
system_profiler 'SPSoftwareDataType' 'SPHardwareDataType' 'SPNVMeDataType'
# Create a 2GB RAM disk
hdiutil attach -nomount 'ram://4194304'
# Eject disks
hdiutil attach '/dev/disk5'
diskutil unmount '/dev/disk7'
diskutil unmountDisk '/dev/disk6'
# Initialize and mount volumes
diskutil erasevolume HFS+ 'ramdisk' '/dev/disk4'
hdiutil attach -nomount 'ram://4194304' | xargs diskutil erasevolume HFS+ 'ramdisk'