首页 > 技术文章 > docker相关

dablyo 2019-06-14 15:31 原文

dns
----
/etc/resolv.conf

proxy
-----
 ~/.bashrc
export http_proxy='http://proxyxa.xxx.com.cn:80'
export https_proxy='http://proxyxa.xxx.com.cn:80/'
export no_proxy="10.0.0.0/8,127.0.0.1,.xxx.com.cn"


apt source
-----------
sources.list

apt proxy
-----------
Acquire::http::proxy "http://proxyxa.xxx.com.cn:80/";
Acquire::https::proxy "https://proxyxa.xxx.com.cn:80/";

apt install openssh-server

docker
-------
sudo apt-get update
sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
sudo apt-get update
apt-cache madison docker-ce
sudo apt-get install docker-ce=17.03.3~ce-0~ubuntu-xenial

docker-compose install
--------------
https://github.com/docker/compose/releases


docker proxy
-------------
wang@peer2:~$ sudo mkdir -p /etc/systemd/system/docker.service.d
wang@peer2:~$ sudo touch /etc/systemd/system/docker.service.d/http-proxy.conf
wang@peer2:~$ sudo vi /etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=http://proxyxa.xxx.com.cn:80/" "HTTPS_PROXY=https://proxyxa.xxx.com.cn:80/"
Environment="NO_PROXY=localhost,127.0.0.0/8,*.zte.com.cn,10.0.0.0/8"

docker registry
sudo vi /etc/docker/daemon.json

{
  "registry-mirrors": ["https://registry.docker-cn.com"]
}

docker启动参数

/etc/default/docker


sudo systemctl daemon-reload
sudo systemctl restart docker
systemctl show --property=Environment docker


iptables持久化

iptables -A INPUT -p tcp/udp --dport $port -j ACCEPT
iptables -A OUTPUT -p tcp/udp --sport $port -j ACCEPT
sudo apt-get install iptables-persistent
sudo netfilter-persistent save

 overlay network

docker-node1:192.168.122.120

docker-node2:192.168.122.155

on node1:

sudo nohup ./etcd-v3.0.12-linux-amd64/etcd \
    --name docker-node1 --initial-advertise-peer-urls http://192.168.122.120:2380 \
    --listen-peer-urls http://192.168.122.120:2380 \
    --listen-client-urls http://192.168.122.120:2379,http://127.0.0.1:2379 \
    --advertise-client-urls http://192.168.122.120:2379 \
    --initial-cluster-token etcd-cluster \
    --initial-cluster docker-node1=http://192.168.122.120:2380,docker-node2=http://192.168.122.155:2380 \
    --initial-cluster-state new&

on node2:

sudo nohup ./etcd-v3.0.12-linux-amd64/etcd \
    --name docker-node2 --initial-advertise-peer-urls http://192.168.122.155:2380 \
    --listen-peer-urls http://192.168.122.155:2380 \
    --listen-client-urls http://192.168.122.155:2379,http://127.0.0.1:2379 \
    --advertise-client-urls http://192.168.122.155:2379 \
    --initial-cluster-token etcd-cluster \
    --initial-cluster docker-node1=http://192.168.122.120:2380,docker-node2=http://192.168.122.155:2380 \
    --initial-cluster-state new&

sudo ./etcd-v3.0.12-linux-amd64/etcdctl cluster-health

按照这个测试未成功

 https://blog.csdn.net/qq_37880968/article/details/86747883

推荐阅读