docker basic instructions

sudo docker info View docker status.

jiqing@ThinkPad:~$ sudo docker info
[sudo] password for jiqing: 
Containers: 1
 Running: 0
 Paused: 0
 Stopped: 1
Images: 1
Server Version: 17.12.1-ce
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 3
 Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 9b55aab90508bd389d7654c4baf173a981477d55
runc version: 9f9c96235cc97674e935002fc3d78361b696a69e
init version: 949e6fa
Security Options:
 apparmor
Kernel Version: 4.4.0-121-generic
Operating System: Ubuntu 14.04.5 LTS
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 7.545GiB
Name: ThinkPad
ID: CDSQ:IGPU:FZGN:XIK7:4PSI:XBCV:MBTV:PDFG:BHHA:62Y3:V65H:RW6I
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

sudo docker search searches Docker Hub for eligible images.

jiqing@ThinkPad:~$ sudo docker search centos
NAME                               DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
centos                             The official build of CentOS.                   4249                [OK]                
ansible/centos7-ansible            Ansible on Centos7                              109                                     [OK]
jdeathe/centos-ssh                 CentOS-6 6.9 x86_64 / CentOS-7 7.4.1708 x86_…   94                                      [OK]
consol/centos-xfce-vnc             Centos container with "headless" VNC session…   52                                      [OK]
imagine10255/centos6-lnmp-php56    centos6-lnmp-php56                              40                                      [OK]
tutum/centos                       Simple CentOS docker image with SSH access      39                                      
gluster/gluster-centos             Official GlusterFS Image [ CentOS-7 +  Glust…   28                                      [OK]
centos/mysql-57-centos7            MySQL 5.7 SQL database server                   27                                      
openshift/base-centos7             A Centos7 derived base image for Source-To-I…   22                                      
centos/python-35-centos7           Platform for building and running Python 3.5…   20                                      
kinogmt/centos-ssh                 CentOS with SSH                                 19                                      [OK]
centos/postgresql-96-centos7       PostgreSQL is an advanced Object-Relational …   16                                      
centos/httpd-24-centos7            Platform for running Apache httpd 2.4 or bui…   12                                      
openshift/jenkins-2-centos7        A Centos7 based Jenkins v2.x image for use w…   12                                      
openshift/mysql-55-centos7         DEPRECATED: A Centos7 based MySQL v5.5 image…   6                                       
openshift/jenkins-1-centos7        DEPRECATED: A Centos7 based Jenkins v1.x ima…   4                                

Pull the image from the public network docker hub.

jiqing@ThinkPad:~$ sudo docker pull imagine10255/centos6-lnmp-php56
Using default tag: latest
latest: Pulling from imagine10255/centos6-lnmp-php56
f402e43879a8: Pull complete 
e76184b3b2ef: Pull complete 
c92be21ea534: Pull complete 
ae5dfaaf3d26: Pull complete 
d1614380713d: Pull complete 
1296ca419182: Pull complete 
eb1025bb2c5f: Pull complete 
d761ada82e04: Pull complete 
bd37fe1cf1bc: Pull complete 
720ddecae86e: Pull complete 
3a5e00e20834: Pull complete 
7333af8d24da: Pull complete 
32350ff46b09: Pull complete 
ebce168aa31f: Pull complete 
07a958684e90: Pull complete 
8d46caeb2844: Pull complete 
e355ba831fdf: Pull complete 
2fcf76f7d667: Pull complete 
a3fd51a842a5: Pull complete 
d261a5a31aa6: Pull complete 
80bfae2d4c60: Pull complete 
bff9ad54a247: Pull complete 
be829cd95222: Pull complete 
Digest: sha256:63b3192b5772e252adfd7860712dac16e96315fb16e582f7d17dff32b0c680f0
Status: Downloaded newer image for imagine10255/centos6-lnmp-php56:latest

sudo docker images to view images

jiqing@ThinkPad:~$ sudo docker images
REPOSITORY                        TAG                 IMAGE ID            CREATED             SIZE
hello-world                       latest              e38bc07ac18e        3 weeks ago         1.85kB
imagine10255/centos6-lnmp-php56   latest              ecc74d703eca        18 months ago       1.31GB

delete local mirror

jiqing@ThinkPad:/var/lib/docker$ sudo docker rmi -f e38bc07ac18e
Untagged: hello-world:latest
Untagged: hello-world@sha256:f5233545e43561214ca4891fd1157e1c3c563316ed8e237750d59bde73361e77
Deleted: sha256:e38bc07ac18ee64e6d59cf2eafcdddf9cec2364dfe129fe0af75f1b0194e0c96

start an image

jiqing@ThinkPad:/var/lib/docker$ sudo docker run -it imagine10255/centos6-lnmp-php56
Starting nginx:                                            [  OK  ]
Starting php-fpm:                                          [  OK  ]
Generating SSH2 RSA host key:                              [  OK  ]
Generating SSH1 RSA host key:                              [  OK  ]
Generating SSH2 DSA host key:                              [  OK  ]
Starting sshd:                                             [  OK  ]
[root@518abb0ea706 /]# ifconfig
eth0      Link encap:Ethernet  HWaddr 02:42:AC:11:00:01  
          inet addr:172.17.0.1  Bcast:172.17.255.255  Mask:255.255.0.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:58 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:8100 (7.9 KiB)  TX bytes:0 (0.0 b)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

This is the lnmp service from the mirror.

[root@8e44bd1abf81 home]# exit;
exit

Docker image storage location

jiqing@ThinkPad:/var/lib/docker$ sudo du -sh /var/lib/docker/*
1.4G    /var/lib/docker/aufs
20K /var/lib/docker/builder
100K    /var/lib/docker/containerd
44K /var/lib/docker/containers
4.0K    /var/lib/docker/graph
3.1M    /var/lib/docker/image
9.9M    /var/lib/docker/init
8.0K    /var/lib/docker/linkgraph.db
56K /var/lib/docker/network
20K /var/lib/docker/plugins
4.0K    /var/lib/docker/repositories-aufs
4.0K    /var/lib/docker/runtimes
4.0K    /var/lib/docker/swarm
4.0K    /var/lib/docker/tmp
4.0K    /var/lib/docker/trust
28K /var/lib/docker/volumes

View local containers

jiqing@ThinkPad:~$ sudo docker ps -a
CONTAINER ID        IMAGE                             COMMAND             CREATED             STATUS                        PORTS                      NAMES
1949036422c3        imagine10255/centos6-lnmp-php56   "bash"              13 minutes ago      Up 13 minutes                 22/tcp, 80/tcp, 8080/tcp   vigilant_bhaskara
518abb0ea706        imagine10255/centos6-lnmp-php56   "bash"              18 minutes ago      Exited (0) 13 minutes ago                                elastic_raman

delete container

jiqing@ThinkPad:~$ sudo docker rm -f 8dbc8af6e4ca
8dbc8af6e4ca

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325476214&siteId=291194637