Quick start
This guide will get you up and running with Container CLI by building a simple web server image and running it as a container.Prerequisites
Before you begin, make sure you have installed Container CLI on your Mac with Apple silicon.Start the container service
First, start the services thatcontainer uses:
y and press Enter to proceed.
You only need to start the container service once after each system restart. The service will continue running in the background.
Build your first image
Create a Dockerfile
In the This Dockerfile:
web-test directory, create a file named Dockerfile with this content:- Starts with a Python 3 base image
- Creates a
/contentdirectory - Adds the
curlcommand - Creates a simple HTML landing page
- Configures the container to run a Python web server on port 80
Build the image
Run the The
container build command to create an image named web-test:. at the end tells the builder to use the current directory as the build context.Run your first container
Start the container
Use The
container run to start a container named my-web-server:--detach flag runs the container in the background, and the --rm flag removes the container automatically after it stops.Check container status
List running containers:You should see your web server container running:
The
buildkit container was automatically started to build your image. It remains running to speed up future builds.Interact with your container
Execute commands in the container
Run commands inside your running container usingcontainer exec:
Open an interactive shell
You can also run an interactive shell to explore the container:The
--tty and --interactive flags (often abbreviated as -ti or -it) allow you to interact with the shell from your terminal.Monitor resource usage
Monitor your container’s resource usage with thecontainer stats command:
Clean up
When you’re done, stop the container:--rm flag when starting the container, it will be automatically removed after stopping.
To completely shut down Container CLI, run
container system stop. This stops all containers and the container service.Useful commands and abbreviations
You can save keystrokes by abbreviating commands and options:Optional: Set up local DNS
container includes an embedded DNS service that simplifies access to your containerized applications. To configure a local DNS domain named test:
Next steps
Now that you’ve built and run your first container, explore more features:- Take the full tutorial: Learn how to publish images to a registry and more
- Browse commands: Check out the command reference for all available commands
- Learn key concepts: Read the technical overview to understand how Container CLI works