docker login&push

docker login sampledockerregistry.com 
docker push sampledockerregistry.com/test

extend size of thinpooldev for docker with loop file

There a vg named docker, a lvm named thinpool for docker storage with driver devicemapper.
When that lvm is out of storage, a better way is to add a new disk to extend lvm, but our storage is limited, i have to make use
of some space of lvm for root directory.
So there is this solution for it.

  • Create a dump file.
  • Setup a loop device with the dump file.
  • Create a PV with that loop device
  • Extend VG with the PV
  • Extend LVM with VG
    # create a 10G file with dd
    dd if=/dev/zero of=tmpfile bs=1M count=10000
    losetup /dev/loop2 /PATH/TO/tmpfile
    pvcreate /dev/loop2
    vgextend docker /dev/loop2
    lvextend /dev/docker/thinpool /dev/loop2
    

create thinpool for docker by loop file

  • setup a loop device
    #create a dump file
    dd if=/dev/zero of=loopfileForDockerLVM bs=1M count=30000
    #setup loop device 
    losetup /dev/loop2 loopfileForDockerLVM
    
  • create PV VG LVM on loop device ``` pvcreate /dev/loop2 vgcreate dockerVG /dev/loop2

lvcreate –wipesignatures y -n thinpool dockerVG -l 90%VG lvcreate –wipesignatures y -n thinpoolmeta dockerVG -L 10G lvconvert -y –zero n -c 512K –thinpool dockerVG/thinpool –poolmetadata dockerVG/thinpoolmeta

- convert LVM to thin-pool type 

> lvconvert --type thin-pool dockerVG/dockerLVM

- config auto extend threshold to a LVM 

> write to /etc/lvm/profile/docker-LVM-extend.profile

activation { thin_pool_autoextend_threshold=60 thin_pool_autoextend_percent=20 }

> lvchange --metadataprofile docker-LVM-extend dockerVG/thinpool

### configure default network of docker

The default network of docker is 172.17.0.1/16, it conflicts with the host's IP 172.18.0.1/24,some service is not available outside of the host which docker on(accessible on docker host).  
There is a solution for customization of [docker](https://docs.docker.com/network/bridge/#configure-the-default-bridge-network) network.

```json
{
  "bip": "192.168.1.5/24",
  "fixed-cidr": "192.168.1.5/25",
  "fixed-cidr-v6": "2001:db8::/64",
  "mtu": 1500,
  "default-gateway": "10.20.1.1",
  "default-gateway-v6": "2001:db8:abcd::89",
  "dns": ["10.20.1.2","10.20.1.3"]
}

bip: network bridge IP
dns: dns for docker. 

When I restart docker with configuration above in /etc/dockerdaemon.json, default gateway "10.20.1.1" must belong to the master pool "192.168.1.0/24", error setup default bridge. So i change gateway to 192.168.1.1.

show network of docker

#docker network ls

NETWROK ID    NAME  DRIVE SCOPE
asdfd00sdfl    cliair-host  bridge local

delete bridge docker0

#brctl show
#brctl delbr docker0
//bridge docker0 is still up, cannot delete it
//Solution :
#ifconfig docker0 down
#brctl delbr docker0

Pull a image

Default tag of images pulled by docker is latest, but some images do not have a ‘latest’ tag , you need to specify corresponding tag.

docker pull kubernetesdashboarddev/kubernetes-dashboard-amd64:head

update tag of image

docker tag 7958321275dc docker.io/busybox:v1.0
docmer rmi docker.io/busybox:latest
docker run --name testrun --cpuset-cpus=20,21 --memory='1g' -v /home/test:/opt -d docker.io/busybox:v1.0