# How to Copy Files from Host to Docker Container?

When creating a docker image, you may want to copy some files from the host machine to the docker image. These files may be native libraries, configuration files, or any other files that will be needed at runtime.

## How to add files to Docker container

To copy a specific file from the host machine to the Docker container, you can use the `docker cp` command:

```bash
docker cp source/file.txt container_id:/destination/file.tx
```

- `source/file.txt` - Is a path to the source file
- `container_id` - Is the name of the docker container to which the file will be copied to
- `/destination/file.tx` - Is a destination within the container to which the file will be copied to

You can copy multiple files by specifying a directory instead of a file

```bash
docker cp src/. container_id:/target
```

## Commit changes to new image

Another command you may need is `docker commit`. It can be useful to commit a container’s file changes or settings into a new image. This allows you to debug a container by running an interactive shell, or to export a working dataset to another server.

```bash
docker commit container_id new_image_name
```
