Docker Engine

Install Docker Engine On the Aliyun

  • Login Alyun VM by ssh

uname -r

  • Add the new gpg key

    apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D

    • view /etc/apt/sources.list.d/docker.list

    Add line below:

    deb https://apt.dockerproject.org/repo debian-wheezy main

  • Update the apt package index

    apt-get update

    • Purge the old repo if it exists

    apt-get purge lxc-docker

    • Verfy that apt is pulling from the correct repository

    apt-cache policy docker-engine

    • Install recommended prerequisites for the OS

    apt-get update apt-get install linux-image-extra-$(uname -r)

    • Install Docker Engine on the remote instance

    sudo apt-get udpate apt-get install docker-engine

    • Start the Docker daemon

    sudo service docker start

  • check install's result

[email protected]:/usr/lib/apt/methods# docker version
Client:
 Version:      1.10.3
 API version:  1.22
 Go version:   go1.5.3
 Git commit:   20f81dd
 Built:        Thu Mar 10 15:48:06 2016
 OS/Arch:      linux/amd64

Server:
 Version:      1.10.3
 API version:  1.22
 Go version:   go1.5.3
 Git commit:   20f81dd
 Built:        Thu Mar 10 15:48:06 2016
 OS/Arch:      linux/amd64

 * but now only two commands availabe  on aliyun, on physical host will have pluse command docker-machine etc.

 [email protected]:/usr/lib/apt/methods# docker
docker           docker-registry

* So How to install Docker machine on aliyun

curl -L https://github.com/docker/machine/releases/download/v0.6.0/docker-machine-`uname -s`-`uname -m` > /usr/local/bin/docker-machine && \

chmod +x /usr/local/bin/docker-machine

but run result below:

[email protected]:/usr/lib/apt/methods# docker-machine -v
Segmentation fault


* Launch a container on the default network

Docker includes support for networking containers through the use of network drivers. By Default. Docker provides two network drivers for you , the bridge and the overlay drivers. You can also write a network driver plugin so that you can create your own drivers but that is an advanced task.

Docker Engine natively supports both bridge networks and overlay networks. A bridge network is limited to a single host running Docker Engine. An overlay network can include multiple hosts and is a more advanced topic.

* Create your own bridge network

1. docker network create -d bridge my-bridge-network

2. docker network ls

3. docker network inspect my-bridge-network

4. Add containers to a network

 docker run -d --net=my-bridge-network --name db node:5.5.0-wheezy

 docker inspect --format='{{json .NetworkSettings.Networks}}'  db

 5. docker network connect my-bridge-network web

* Automated Builds

[Automated Builds](https://docs.docker.com/engine/userguide/containers/dockerrepos/)

Automated Builds automate the building and updating of images from GitHub or Bitbucket, directly on Docker Hub. It works by adding a commit hook to your selected GitHub or Bitbucket repository, triggering a build and update when you push a commit.


* Build Triggers

Trigger your Automated Build by sending a POST to a specific endpoint

Trigger Token: c43117ae-ab0f-490d-bcb8-2e5058a818f1
Trigger URL:
https://registry.hub.docker.com/u/hujb2000/easynode-ipc/trigger/c43117ae-ab0f-490d-bcb8-2e5058a818f1/

* Migration example

sudo du -hs /var/lib/docker

time docker run --rm -v /var/lib/docker:/var/lib/docker docker/v1.10-migrator

* Select a storage driver

You can set the storage driver by passing the --storage-driver=<name> option to the docker daemon command line, or by setting the option on the DOCKER_OPTS line in the /etc/default/docker file.


* An overaly network

Docker's overlay network driver supports multi-host networking natively out-of-the-box. This  support is accomplished with the help of libnetwork, a build-in VXLAN-based overlay network driver. and Docker's libkv library.

The overlay network requires a valid key-value store service. Currently . Docker's libkv supports Consul, Etcd, and ZooKeeper(Distributed store). Before creating a network you must install  and configure yor chosen key-value store service. The Docker hosts hat you intend to network and the service must be able to communicate.

You should  open the following ports  between each of your hosts.
udp      4789    Data plane(VXLAN)
tcp/udp  7946    Control plane.

--cluster-store=PROVIDER://URL
Describes the location of the KV service.

--cluster-advertise=HOST_IP|HOST_IFACE:PORT
The IP address or interface of the HOST used for clustering.

--cluster-store-opt=KEY-VALUE OPTIONS
Options such as TLS certificate or tuning discovery Timers

Recommended to use the --subnet;

docker network create -d overlay --subnet=192.168.0.0/16 --subnet=192.170.0.0/16 --gateway=192.168.0.100 --gateway=192.170.0.100 --ip-range=192.168.1.0/24 --aux-address a=192.168.1.5 --aux-address b=192.168.1.6 --aux-address a=192.170.1.5 --aux-address b=192.170.1.6 my-multihost-network

  • Custom network plugin

  • Docker embedded DNS server

Docker daemon runs an embedded DNS server to provide automatic service discovery for containers connected to user defined networks

  • Get started with multi-host networking

overlay network require some pre-existing conditions before you can reate a multi-host networking.

  1. Access to a key-value store, Docker supports Consul, Etcd, and ZooKeeper
  2. A cluster of hosts with c onnectivity to the key-value store.
  3. A property configured Engine daemon on each host in the cluster.
  4. Hosts within the cluster must have unique hostnames because the key-value store uses the hostnames to identify cluster members.

Q:

  1. How do I fix a “E: The method driver /usr/lib/apt/methods/http could not be found.” error?

sudo apt-get install apt-transport-https

  1. Enable AppArmor and SELinux when possible

Please use AppArmor or SELinux if your Linux distribution supports either of the two. This helps improve security and blocks certain types of exploits.

  1. Giving non-root access

Add your user account to the docker group sudo usermod -aG docker

adduser hjb sudo