linux:docker
This is an old revision of the document!
Docker
https://docs.docker.com/storage/volumes/
Copying files from/to images
docker cp dockerimage:/bla ./bla docker cp ./bla dockerimage:/bla
Change mount points of existing docker containers;
e.g. mount /home/<user-name> folder of host to the /mnt folder of the existing (not running) container.
- stop docker container or whole docker engine
systemctl stop docker.service
- Open configuration file corresponding to the stopped container, which can be found at /var/lib/docker/containers/99d…1fb/config.v2.json (may be config.json for older versions of docker). For pretty print use
vi <(jq . /var/lib/docker/containers/<container-ID>/config.v2.json) Save updates to a file: :w config.v2.json Exit vim: :q! Update existing file: jq -c . config.v2.json > /var/lib/docker/containers/<container-ID>/config.v2.json
- Find MountPoints section: “MountPoints”:{}.
- Replace the contents with something like this (you can copy proper contents from another container with proper settings):
"MountPoints":{"/mnt":{"Source":"/home/<user-name>","Destination":"/mnt","RW":true,"Name":"","Driver":"","Type":"bind","Propagation":"rprivate","Spec":{"Type":"bind","Source":"/home/<user-name>","Target":"/mnt"},"SkipMountpointCreation":false}}
or the same (formatted):
"MountPoints": { "/mnt": { "Source": "/home/<user-name>", "Destination": "/mnt", "RW": true, "Name": "", "Driver": "", "Type": "bind", "Propagation": "rprivate", "Spec": { "Type": "bind", "Source": "/home/<user-name>", "Target": "/mnt" }, "SkipMountpointCreation": false } }
- Start or restart the docker service:
systemctl start docker.service service docker restart
- Start the container if necessary:
docker start <container-name/ID>
linux/docker.1685357733.txt.gz · Last modified: 2023/05/29 11:55 by 127.0.0.1