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