mirror of
https://github.com/wsargent/docker-cheat-sheet.git
synced 2025-12-16 23:20:13 +01:00
Volumes can be files
Just wanted to add that is possible to mount files as volumes. Don't know if that is worth mentioning. But it can be useful if you want to toy around with a image from [Docker Hub](https://hub.docker.com) without writing your own Dockerfile.
This commit is contained in:
parent
b325798014
commit
8f8c01a772
1 changed files with 17 additions and 0 deletions
17
README.md
17
README.md
|
|
@ -429,6 +429,8 @@ You can use remote NFS volumes if you're [feeling brave](https://docs.docker.com
|
|||
|
||||
You may also consider running data-only containers as described [here](http://container42.com/2013/12/16/persistent-volumes-with-docker-container-as-volume-pattern/) to provide some data portability.
|
||||
|
||||
[Be aware that you can mount files as volumes.](#volumes-can-be-files)
|
||||
|
||||
## Exposing ports
|
||||
|
||||
Exposing incoming ports through the host container is [fiddly but doable](https://docs.docker.com/engine/reference/run/#expose-incoming-ports).
|
||||
|
|
@ -770,6 +772,21 @@ Remove all exited containers
|
|||
docker rm -f $(docker ps -a | grep Exit | awk '{ print $1 }')
|
||||
```
|
||||
|
||||
### Volumes can be files
|
||||
|
||||
Be aware that you can mount files as volumes. For example you can inject a configuration file like this:
|
||||
|
||||
``` bash
|
||||
# copy file from container
|
||||
docker run --rm httpd cat /usr/local/apache2/conf/httpd.conf > httpd.conf
|
||||
|
||||
# edit file
|
||||
vim httpd.conf
|
||||
|
||||
# start container with modified configuration
|
||||
docker run --rm -ti -v "$PWD/httpd.conf:/usr/local/apache2/conf/httpd.conf:ro" -p "80:80" httpd
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
Here's how to contribute to this cheat sheet.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue