/docs/MyDocs

To get this branch, use:
bzr branch http://darksoft.org/webbzr/docs/MyDocs

« back to all changes in this revision

Viewing changes to Administration/Server/Virtualization/containers/docker/docker.txt

  • Committer: Suren A. Chilingaryan
  • Date: 2017-04-03 02:45:17 UTC
  • Revision ID: csa@suren.me-20170403024517-dwzj0z0k1cmhxm7u
Restructuring, OpenShift, Ansible, Git

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
Hub
3
 
---
4
 
 docker search
5
 
 docker pull opensuse
6
 
 
7
 
 docker pull registry                                   - get image with running registry (local docker hub)
8
 
 
9
 
 
10
 
Working with images
11
 
-------------------
12
 
 docker images                                          - local images
13
 
 docker history <image>                                 - show the building history of the image        
14
 
 docker build --tag  chsa/adei .                        - build new image using Dockerfile
15
 
 docker push chsa/adei                                  - publish on docker hub
16
 
 
17
 
Working with containers
18
 
-----------------------
19
 
 docker run -it chsa/adei /bin/bash                     - Create the container and start it
20
 
    -it                                 - Interactive, i.e. terminal to the sssion
21
 
    -d                                  - Start detached container (allows running multiple copies of the same image)
22
 
    -rm                                 - Automatically remove on stop
23
 
    -P                                  - Publish all listening container ports to host  system (ports are not necessarily the same, find out with docker port)
24
 
    -p [host_port:virt_port]            - Instruct to map ports (uses DOCKER chain in nat & default iptables)
25
 
  * Volumes
26
 
    --link container:alias              - Allow to connect to '<container>' from the newly running container as 'alias' and will also 
27
 
                                        add some environmental variables about it configuration (check with set | grep MYSQL)
28
 
    --volumes-from <container>          - mount all mounts from the specified container (if corresponding directories exists)
29
 
    -v /path                            - provided a permanents storage in the specified location
30
 
    -v /host_path:/path                 - map a host folder in the specified location (also a single file can be mounted)
31
 
  * Resources
32
 
    -m 512MB                            - limit amount of memory available for container
33
 
    --cpuset-cpus 0-2,5                 - limit CPU cores which will run container (efficiently may limit CPU usage)
34
 
    --cpu-period 2 --cpu-quota 4        - Tell CFQ scheduler to give VM 4us on CPU for each period of 2us (i.e. allow full usage of 2 CPU cores), the default period is 100,000us
35
 
    
36
 
 
37
 
 docker port adei-mysql 3306                            - report there is mapped the specified port of container
38
 
 docker top adei-mysql                                  - usage
39
 
 docker logs adei-mysql                                 - display logs
40
 
        
41
 
 docker ps [-a]                                         - list running (and terminated) containers
42
 
 docker inspect adei-mysql                              - get information about container (environment, mounts, etc.)
43
 
 docker exec -ti adei-mysql  /bin/bash                  - run additional command in running container context
44
 
 docker stop/start                                      - stop / restart stopped container
45
 
 docker attach                                          - attach to terminal of the container
46
 
 
47
 
 
48
 
 docker commit <name> chsa/adei                         - save modified container as an image
49
 
 docker export -o state.tar <name>                      - preserve the current state
50
 
 docker rm <name>                                       - destroy currently runnign container
51
 
    -v                                  - remove all associated volumes
52
 
 
53
 
Commands
54
 
--------
55
 
 * Remove all stopped containers
56
 
    docker rm $(docker ps -q -f status=exited)
57
 
 
58
 
 
59
 
 
60