File tree Expand file tree Collapse file tree 3 files changed +20
-14
lines changed Expand file tree Collapse file tree 3 files changed +20
-14
lines changed Original file line number Diff line number Diff line change @@ -170,10 +170,20 @@ The tool includes an intelligent caching system for OCI images:
170170
171171## Usage
172172
173+ Basic workflow for creating containers:
173174``` bash
174- # Start containers
175- lxc-compose up
175+ # 1. Pull the image
176+ lxc-compose images pull alpine:3.19
176177
178+ # 2. Convert it to LXC format
179+ lxc-compose convert alpine:3.19
180+
181+ # 3. Create and start containers
182+ lxc-compose up -f your-compose.yml
183+ ```
184+
185+ Other common commands:
186+ ``` bash
177187# Stop containers
178188lxc-compose down
179189
@@ -200,18 +210,20 @@ This will convert the Ubuntu 20.04 Docker image to an LXC template.
200210
201211### Configuration File (lxc-compose.yml)
202212
213+ The service key in your configuration will be used as the container name.
214+
203215``` yaml
204216version : " 1.0"
205217services :
206- web :
218+ # This container will be named "nginx-web"
219+ nginx-web : # <- This key is used as the container name
207220 image : ubuntu:20.04
208221 security :
209222 isolation : strict
210223 apparmor_profile : lxc-container-default-restricted
211224 capabilities :
212225 - NET_ADMIN
213226 - SYS_TIME
214- selinux_context : system_u:system_r:container_t:s0
215227 cpu :
216228 cores : 2
217229 shares : 1024
Original file line number Diff line number Diff line change @@ -31,13 +31,6 @@ func upCmdRunE(_ *cobra.Command, args []string) error {
3131 return fmt .Errorf ("failed to load config: %w" , err )
3232 }
3333
34- // Convert to compose config type
35- var compose common.ComposeConfig
36- compose .Services = make (map [string ]common.Container )
37- if cfg != nil {
38- compose .Services ["default" ] = cfg .Services ["default" ]
39- }
40-
4134 // Create container manager
4235 manager , err := container .NewLXCManager ("/var/lib/lxc" )
4336 if err != nil {
@@ -47,13 +40,14 @@ func upCmdRunE(_ *cobra.Command, args []string) error {
4740 // Start all or specified services
4841 services := args
4942 if len (services ) == 0 {
50- for name := range compose .Services {
43+ // If no services specified, start all
44+ for name := range cfg .Services {
5145 services = append (services , name )
5246 }
5347 }
5448
5549 for _ , name := range services {
56- svcCfg , ok := compose .Services [name ]
50+ svcCfg , ok := cfg .Services [name ]
5751 if ! ok {
5852 return fmt .Errorf ("service '%s' not found in config" , name )
5953 }
Original file line number Diff line number Diff line change 11version : " 1.0"
22services :
3- nginx :
3+ nginx-alpine :
44 image : alpine:3.19
55 security :
66 isolation : strict
You can’t perform that action at this time.
0 commit comments