container/docs/container-machine.md at main · apple/container · GitHub
//blob/show" data-turbo-transient="true" />
Skip to content
Search or jump to...
Search code, repositories, users, issues, pull requests...
-->
Search
Clear
Search syntax tips
Provide feedback
--><br>We read every piece of feedback, and take your input very seriously.
Include my email address so I can be contacted
Cancel
Submit feedback
Saved searches
Use saved searches to filter your results more quickly
-->
Name
Query
To see all available qualifiers, see our documentation.
Cancel
Create saved search
Sign in
//blob/show;ref_cta:Sign up;ref_loc:header logged out"}"<br>Sign up
Appearance settings
Resetting focus
You signed in with another tab or window. Reload to refresh your session.<br>You signed out in another tab or window. Reload to refresh your session.<br>You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
{{ message }}
apple
container
Public
Notifications<br>You must be signed in to change notification settings
Fork<br>781
Star<br>27k
FilesExpand file tree
main
/container-machine.md
Copy path
Blame<br>More file actions
Blame<br>More file actions
Latest commit
History<br>History<br>History
120 lines (85 loc) · 5.06 KB
main
/container-machine.md
Top
File metadata and controls<br>Preview
Code
Blame
120 lines (85 loc) · 5.06 KB
Raw<br>Copy raw file<br>Download raw file
OutlineEdit and raw actions
Container machine
Container machine provides a highly integrated Linux environment that works seamlessly on your Mac. Container machines are fast, lightweight and persistent. They are based on standard OCI images that can be built and shared. Host integrations such as automatic user and home directory sharing provide quick and easy access to your Linux environment no matter where you are in a terminal.
Why container machines
Containers are typically modeled after an application. A container machine is modeled after a Linux environment. It runs the image's init system allowing you to register long running services or test your application under a process supervisor.<br>A container machine automatically maps your username and home directory into the Linux environment. Your repositories and dotfiles are available on both platforms. Use editors and tools directly on macOS simultaneously building and running your application inside of the Linux environment.
Edit on the Mac, build inside. Your repo lives in $HOME on macOS and is mounted at /Users/ inside the container machine. Use your macOS editor or IDE; compile and run inside your container machine.
Use macOS-native tooling against Linux artifacts. Profilers, screenshot tools, browsers, and GUI debuggers on your Mac all see the same files the container machine sees — there is no copy step between "I built it" and "I am inspecting it".
Real Linux services for testing. Run a database or whatever your stack needs as a system service — systemctl start postgresql works on images with systemd installed.
One environment per target distro. Create as many container machines as you have target distros — alpine, ubuntu, debian. Each has the same $HOME and the same dotfiles from your Mac. Quickly test your application in various distributions.
Quickstart
— your Mac home dir, mounted in<br>container machine run -n dev # interactive shell; cd into your repos in $HOME">container machine create alpine:latest --name dev<br>container machine run -n dev whoami # your host username, not root<br>container machine run -n dev pwd # /home/ — your Mac home dir, mounted in<br>container machine run -n dev # interactive shell; cd into your repos in $HOME
container machine run is how you get a shell or run a single command. If the container machine is stopped, run boots it first.
Working in a container machine
Open a shell, or run a single command
With no command, container machine run opens an interactive shell as a user that matches your host account:
container machine run -n dev
Pass a command to run it once and exit:
container machine run -n dev uname -a<br>container machine run -n dev -- cat /proc/cpuinfo
Set a default
Pick a default container machine so you can drop the -n flag:
container machine set-default dev<br>container machine run # operates on dev
List, inspect, stop, delete
container machine ls # list all container machines<br>container machine inspect dev # JSON detail for one<br>container machine stop dev # stop the container machine<br>container machine rm dev # delete, including its persistent storage
container machine has the alias m, so m ls, m run, etc. all work.
Resize CPUs, memory, or change the home-mount
container machine set updates configuration on disk. Changes take effect after the next stop and start:
container machine set -n dev cpus=4 memory=8G<br>container machine stop dev<br>container machine run -n dev -- nproc
Memory defaults to half of host memory. The home-mount can be rw (default), ro, or none.
Bring your own container machine image
Any...