Skip to content

Commit 821d2b6

Browse files
committed
Update Docs
1 parent dd5e9d3 commit 821d2b6

3 files changed

Lines changed: 59 additions & 0 deletions

File tree

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ integration: init-block
184184
$(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --filter TestCLIRunLifecycle || exit_code=1 ; \
185185
$(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --filter TestCLIExecCommand || exit_code=1 ; \
186186
$(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --filter TestCLICreateCommand || exit_code=1 ; \
187+
$(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --filter TestCLICopyCommand || exit_code=1 ; \
187188
$(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --filter TestCLIRunCommand1 || exit_code=1 ; \
188189
$(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --filter TestCLIRunCommand2 || exit_code=1 ; \
189190
$(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --filter TestCLIRunCommand3 || exit_code=1 ; \

docs/command-reference.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,39 @@ container stats --no-stream web
424424
container stats --format json --no-stream web
425425
```
426426

427+
### `container copy (cp)`
428+
429+
Copies files between a container and the local filesystem. The container must be running. One of the source or destination must be a container reference in the form `container_id:path`.
430+
431+
**Usage**
432+
433+
```bash
434+
container copy [--debug] <source> <destination>
435+
```
436+
437+
**Arguments**
438+
439+
* `<source>`: Source path (local path or `container_id:path`)
440+
* `<destination>`: Destination path (local path or `container_id:path`)
441+
442+
**Path Format**
443+
444+
* Local path: `/path/to/file` or `relative/path`
445+
* Container path: `container_id:/path/in/container`
446+
447+
**Examples**
448+
449+
```bash
450+
# copy a file from host to container
451+
container cp ./config.json mycontainer:/etc/app/
452+
453+
# copy a file from container to host
454+
container cp mycontainer:/var/log/app.log ./logs/
455+
456+
# copy using the full command name
457+
container copy ./data.txt mycontainer:/tmp/
458+
```
459+
427460
### `container prune`
428461

429462
Removes stopped containers to reclaim disk space. The command outputs the amount of space freed after deletion.

docs/how-to.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,31 @@ total 4
6060
%
6161
</pre>
6262

63+
## Copy files between host and container
64+
65+
Use `container copy` (or the short alias `container cp`) to transfer files between a running container and your local filesystem.
66+
67+
To copy a local file into a running container:
68+
69+
<pre>
70+
% echo "hello" > greeting.txt
71+
% container cp greeting.txt mycontainer:/tmp/
72+
% container exec mycontainer cat /tmp/greeting.txt
73+
hello
74+
%
75+
</pre>
76+
77+
To copy a file from a container to the host:
78+
79+
<pre>
80+
% container cp mycontainer:/etc/hostname ./hostname.txt
81+
% cat hostname.txt
82+
mycontainer
83+
%
84+
</pre>
85+
86+
The path format uses a colon to distinguish container paths from local paths: `container_id:/path/in/container`. One of the source or destination must always be a container reference. The container must be running for the copy to succeed.
87+
6388
## Build and run a multiplatform image
6489

6590
Using the [project from the tutorial example](tutorial.md#set-up-a-simple-project), you can create an image to use both on Apple silicon Macs and on x86-64 servers.

0 commit comments

Comments
 (0)