@@ -321,6 +321,79 @@ for container names are:
321
321
The import does not try to determine dependencies and will use the folder name as the project
322
322
and dirname values.
323
323
324
+ # ## Working with services
325
+
326
+ # ### Starting
327
+
328
+ ` spm` provides several wrappers to help with starting / stopping and getting an overview of the
329
+ current projects services. All services commands are prefixed with `services:`. Once you have
330
+ added some services you can list them : ` spm services:list` and then start one or more:
331
+ `spm services:start service1 service2 service3` or start all of the services :
332
+ ` spm services:start all` . `services:start` is aliased to `start`
333
+
334
+ If you have defined dependencies and have not specified either `-d` to automatically start
335
+ dependencies, or `-D` to not start dependencies; you will be prompted if you wish to start
336
+ the dependencies first or not. If you opt to start services, then all dependencies will be
337
+ resolved and started first. You will not be prompted again after being asked the first time.
338
+
339
+ # ### Status Overview
340
+
341
+ To get an overview of the current project services : ` spm services:status` . This will query
342
+ Docker to get assorted data about all containers that match the preset compose name from the
343
+ project config and display the information in a table. This information includes :
344
+
345
+ * running container name
346
+ * current status (up/down etc)
347
+ * the host if it has been set e.g. for traefik or the IP for the external DB connection
348
+ * external port(s)
349
+ * any volumes connected to the container
350
+
351
+ # ### Stopping
352
+
353
+ To stop a service use : ` spm services:stop service1 service2` or `spm services:stop all` to stop
354
+ all running services. Services that have dependencies will automatically cause dependent services
355
+ to be stopped as well. For example : if you have a main data service that provides databases and
356
+ your apps depend on this and you stop it, then all the dependent services will be stopped first.
357
+ ` services:stop` is aliased to `stop`.
358
+
359
+ The docker logs can be viewed by running : ` spm services:log service` or use the alias `log`. Add
360
+ ` -f` to follow the log and use Ctrl+C to stop.
361
+
362
+ # ### Rebuilding / cleaning the docker containers
363
+
364
+ If you encounter major issues with your containers or just want to reset to a completely clean
365
+ state, either use : ` docker system prune --all --volumes` or `spm services:reset`. The `spm`
366
+ command calls the same options under-the-hood.
367
+
368
+ For less drastic rebuilds, the `services:start` command allows for :
369
+
370
+ * `--rebuild / -b` - rebuild containers and then start
371
+ * `--refresh / -r` - refresh and start
372
+
373
+ The difference between build and refresh is that refresh will force pull any new images as well
374
+ as rebuild the container images. Use this if the upstream image has been updated and you need
375
+ a new version instead of the cached version.
376
+
377
+ # ### Copy files to/from containers
378
+
379
+ You can easily copy files to/from your running containers by using : ` spm services:copy` that is
380
+ aliased as `copy` and `cp`. Note : that one side of this command must be a service name specified
381
+ as `service_name:/path/in/container`.
382
+
383
+ The format is : ` spm services:copy source target` , for example to copy a file from your downloads
384
+ into the users-app container, configured as `users` :
385
+
386
+ ` ` ` shell script
387
+ spm services:copy ~/Downloads/file.txt users:/app/tmp/file.txt
388
+ ` ` `
389
+
390
+ Under-the-hood, `services:copy` uses `docker cp`.
391
+
392
+ __Note:__ the copy command uses the **service** name; _not_ the actual docker container name!
393
+
394
+ __Note:__ the copy command uses the current working directory and not the services path when it
395
+ is running. Run `spm services:copy -h` for help and the current working folder.
396
+
324
397
# ## Setting Remote Repositories
325
398
326
399
By default when using `project:create`, `libraries:create` or `services:create` a git repository
0 commit comments