meta data for this page
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
linux:docker [2017/02/08 13:34] – [run backup on existing volume] niziak | linux:docker [2019/04/03 12:09] – [Volumes] niziak | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | * Docker image - operating system with preconfigured application (service) | + | |
- | * Docker container - running instance created from docker image | + | |
- | * Data volume - persistent storage of data outside of container. Can be shared between containers. | + | |
- | * Dockerfile - is a recipe which describes the files, environment, | + | |
- | * docker-compose - tool for defining and running multi-container Docker application (e.g. web app + mysql db). Compose preserves all volumes used by your services. When docker-compose up runs, if it finds any containers from previous runs, it copies the volumes from the old container to the new container. | + | |
====== command line ====== | ====== command line ====== | ||
===== run ===== | ===== run ===== | ||
+ | Create __new__ container based on image and execute optional command inside. | ||
+ | <code bash> | ||
+ | docker run -i --rm busybox | ||
+ | docker run -i --rm busybox ps aux | ||
+ | docker run -i --rm debian: | ||
+ | docker run -i --rm nginx bash | ||
+ | </ | ||
+ | |||
* **docker run** - run __new__ isolated container ... | * **docker run** - run __new__ isolated container ... | ||
Line 23: | Line 31: | ||
</ | </ | ||
- | <code bash> | + | How to run multiple shell commands in docker at once: |
- | docker run debian: | + | <code bash> |
- | </ | + | |
- | === stopping === | + | ==== stopping |
'' | '' | ||
docker stop ----time=30 foo | docker stop ----time=30 foo | ||
Line 36: | Line 44: | ||
More on handling signals [[https:// | More on handling signals [[https:// | ||
- | === restart policy === | + | ==== restart policy |
<code bash> | <code bash> | ||
Line 76: | Line 84: | ||
Data volumes are designed to persist data, independent of the container’s life cycle. Docker therefore never automatically delete volumes when you remove a container, nor will it “garbage collect” | Data volumes are designed to persist data, independent of the container’s life cycle. Docker therefore never automatically delete volumes when you remove a container, nor will it “garbage collect” | ||
A Docker data volume persists after a container is deleted. | A Docker data volume persists after a container is deleted. | ||
+ | |||
+ | Volumes types: | ||
+ | * local storage (original image data located in specified directory | ||
+ | * bind-mounted host (original image data are **not copied**) | ||
+ | * volume plugins | ||
+ | |||
+ | Move volume between discs: | ||
+ | <code bash> | ||
+ | |||
+ | ===== BTRFS Volume plugin for Docker ===== | ||
+ | [[https:// | ||
+ | |||
+ | |||
+ | Volume destination inside container must be a absolute path. | ||
+ | |||
+ | Run shell with mounted volume from another docker: | ||
+ | <code bash> | ||
+ | <code bash> | ||
Single file can be mounted as volume: | Single file can be mounted as volume: | ||
Line 95: | Line 121: | ||
</ | </ | ||
- | ====== Network ====== | + | Transfer volume to another host [[https:// |
- | [[http://blog.oddbit.com/2014/08/11/four-ways-to-connect-a-docker/]] | + | [[https://github.com/gdiepen/docker-convenience-scripts/blob/master/docker_get_data_volume_info.sh]] |
- | [[http://stackoverflow.com/ | + | |
====== data persistence in swarm ====== | ====== data persistence in swarm ====== | ||
Line 109: | Line 134: | ||
* running container: | * running container: | ||
* pause (but what with not flushed data?) | * pause (but what with not flushed data?) | ||
- | * commit container as image | + | * commit container as image (volumes are not included!) |
* backup a image using '' | * backup a image using '' | ||
* backup data volumes | * backup data volumes | ||
Line 158: | Line 183: | ||
</ | </ | ||
+ | <code bash> | ||
docker build -t mydocker . | docker build -t mydocker . | ||
docker run mydocker | docker run mydocker | ||
+ | </ | ||
====== ns ====== | ====== ns ====== | ||
+ | |||
+ | |||
+ | ====== Issues ====== | ||
+ | ===== endpoint with name portainer already exists in network bridge ===== | ||
+ | <code bash> | ||
+ | # docker start 7cda5b580e16 | ||
+ | Error response from daemon: endpoint with name portainer already exists in network bridge | ||
+ | Error: failed to start containers: 7cda5b580e16 | ||
+ | </ | ||
+ | |||
+ | https:// | ||
+ | |||
+ | Typically when you see containers in docker network inspect output with a ep- prefix, that means it can be either of 2 cases - | ||
+ | these are stale endpoints left over in the DB. For those cases, docker network disconnect should help. | ||
+ | these are remote endpoints seen in other nodes that are part of the overlay network. The only way to clean them up are from that specific host. | ||
+ | |||
+ | |||
+ | Not helping: | ||
+ | <code bash> | ||
+ | <code bash> | ||
+ | |||
+ | |||
+ | |||
+ | Helps: | ||
+ | <code bash>/ | ||