meta data for this page
  •  

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
linux:docker [2017/02/08 15:00] – [run] niziaklinux:docker [2020/05/07 09:05] (current) niziak
Line 1: Line 1:
 +====== Docker ======
  
-  * Docker image - operating system with preconfigured application (service) +  * **Docker image** - operating system with preconfigured application (service) 
-  * Docker container - running instance created from docker image +  * **Docker container** - running instance created from docker image 
-  * Data volume - persistent storage of data outside of container. Can be shared between containers. +  * **Data volume** - persistent storage of data outside of container. Can be shared between containers. 
-  * Dockerfile - is a recipe which describes the files, environment, and commands that make up an image. +  * **Dockerfile** - is a recipe which describes the files, environment, and commands that make up an image. 
-  * 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.    This process ensures that any data you’ve created in volumes isn’t lost.+  * **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.    This process ensures that any data you’ve created in volumes isn’t lost.
  
 ====== command line ====== ====== command line ======
Line 31: Line 32:
 </code> </code>
  
 +How to run multiple shell commands in docker at once:
 +<code bash>docker run image /bin/bash -c "cd /some/path && some_command"</code>
  
-=== stopping ===+ 
 +==== stopping ====
 ''docker stop'' sends ''SIGTERM'' to PID1 and waits 10 seconds before force kill ''SIGKILL''. ''docker stop'' sends ''SIGTERM'' to PID1 and waits 10 seconds before force kill ''SIGKILL''.
   docker stop ----time=30 foo   docker stop ----time=30 foo
Line 41: Line 45:
 More on handling signals [[https://www.ctl.io/developers/blog/post/gracefully-stopping-docker-containers/]] More on handling signals [[https://www.ctl.io/developers/blog/post/gracefully-stopping-docker-containers/]]
  
-=== restart policy ===+==== restart policy ====
  
 <code bash> <code bash>
Line 76: Line 80:
   * https://github.com/ClusterHQ/flocker   * https://github.com/ClusterHQ/flocker
  
-====== Volumes ====== 
-[[https://docs.docker.com/engine/tutorials/dockervolumes/]] 
- 
-  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”     volumes that are no longer referenced by a container. 
-  A Docker data volume persists after a container is deleted. 
- 
-Single file can be mounted as volume: 
-<code bash>docker run --rm -it -v ~/.bash_history:/root/.bash_history debian:jessie-slim bash /bin/bash</code> 
- 
-Create named volume and share it between multiple containers: 
-<code bash> 
-docker run -d -P -v my-named-volume:/opt --name test1 debian:jessie-slim bash 
-docker run -d -P -v my-named-volume:/opt --name test2 debian:jessie-slim bash 
-docker run -d -P -v my-named-volume:/opt --name test3 debian:jessie-slim bash 
-</code> 
- 
-To protect data from being deleted with volume use ''local-persist'' plugin: [[https://github.com/CWSpear/local-persist]] 
- 
-Find orphaned volumes 
-<code bash> 
-docker volume ls -f dangling=true 
-docker volume rm <volume name> 
-</code> 
- 
-====== Network ====== 
- 
-[[http://blog.oddbit.com/2014/08/11/four-ways-to-connect-a-docker/]] 
-[[http://stackoverflow.com/questions/26539727/giving-a-docker-container-a-routable-ip-address]] 
- 
-====== data persistence in swarm ====== 
-[[http://mysqlrelease.com/2016/08/trying-out-mysql-in-docker-swarm-mode/]] 
-[[https://forums.docker.com/t/data-base-persistence-in-docker-swarm-mode/20665/7]] 
  
 ====== Backup ====== ====== Backup ======
Line 163: Line 135:
 </file> </file>
  
 +<code bash>
 docker build -t mydocker . docker build -t mydocker .
 docker run mydocker docker run mydocker
 +</code>
  
 ====== 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
 +</code>
 +
 +https://github.com/moby/moby/issues/23302
 +
 +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>docker network prune</code>
 +<code bash>docker network disconnect -f bridge portainer</code>
 +
 +
 +
 +Helps:
 +<code bash>/etc/init.d/docker restart</code>