docs/current_docs/partials/cookbook/filesystems/_modify-copied-directory.mdx
The following Dagger Function accepts a Directory argument, which could reference either a directory from the local filesystem or from a remote Git repository. It copies the specified directory to the /src path in a container, adds a file to it, and returns the modified container.
:::warning When a host directory or file is copied or mounted to a container's filesystem, modifications made to it in the container do not automatically transfer back to the host.
Data flows only one way between Dagger operations, because they are connected in a DAG. To transfer modifications back to the local host, you must explicitly export the directory or file back to the host filesystem. :::
:::note When working with private Git repositories, ensure that SSH authentication is properly configured on your Dagger host. :::
<Tabs groupId="language" queryString="sdk"> <TabItem value="go" label="Go">Examples
Copy the /myapp host directory to /src in the container, add a file to it, and return the modified container:
<Tabs groupId="shell">
<TabItem value="System shell">
```shell
dagger -c 'copy-and-modify-directory ./myapp/'
```
</TabItem>
<TabItem value="Dagger Shell">
```shell title="First type 'dagger' for interactive mode."
copy-and-modify-directory ./myapp/
```
</TabItem>
<TabItem value="Dagger CLI">
```shell
dagger call copy-and-modify-directory --source=./myapp/
```
</TabItem>
</Tabs>
Copy the public dagger/dagger GitHub repository to /src in the container, add a file to it, and return the modified container:
<Tabs groupId="shell">
<TabItem value="System shell">
```shell
dagger -c 'copy-and-modify-directory github.com/dagger/dagger#main'
```
</TabItem>
<TabItem value="Dagger Shell">
```shell title="First type 'dagger' for interactive mode."
copy-and-modify-directory github.com/dagger/dagger#main
```
</TabItem>
<TabItem value="Dagger CLI">
```shell
dagger call copy-and-modify-directory --source=github.com/dagger/dagger#main
```
</TabItem>
</Tabs>
Copy the private user/foo GitHub repository to /src in the container, add a file to it, and return the modified container:
<Tabs groupId="shell">
<TabItem value="System shell">
```shell
dagger -c 'copy-and-modify-directory ssh://[email protected]/user/foo#main'
```
</TabItem>
<TabItem value="Dagger Shell">
```shell title="First type 'dagger' for interactive mode."
copy-and-modify-directory ssh://[email protected]/user/foo#main
```
</TabItem>
<TabItem value="Dagger CLI">
```shell
dagger call copy-and-modify-directory --source=ssh://[email protected]/user/foo#main
```
</TabItem>
</Tabs>
Copy the public dagger/dagger GitHub repository to /src in the container, add a file to it, and list the contents of the directory:
<Tabs groupId="shell">
<TabItem value="System shell">
```shell
dagger -c 'copy-and-modify-directory https://github.com/dagger/dagger#main | directory /src | entries'
```
</TabItem>
<TabItem value="Dagger Shell">
```shell title="First type 'dagger' for interactive mode."
copy-and-modify-directory https://github.com/dagger/dagger#main | directory /src | entries
```
</TabItem>
<TabItem value="Dagger CLI">
```shell
dagger call \
copy-and-modify-directory --source=https://github.com/dagger/dagger#main \
directory --path=/src \
entries
```
</TabItem>
</Tabs>