1. 程式人生 > >Ubuntu 18.04安裝 docker 環境

Ubuntu 18.04安裝 docker 環境

ubuntu 18.04 環境安裝

## docker 安裝
apt-get remove docker docker-engine docker.io
## Ubuntu 14.04 可選核心模組
# apt-get update
# apt-get install linux-image-extra-$(uname -r)  linux-image-extra-virtual
#
## 16.04.+
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 -
curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
add-apt-repository  "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
# 16.04
#deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu xenial stable
# 18.04
# deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu bionic stable


# 官方源
# $ sudo add-apt-repository  "deb [arch=amd64] https://download.docker.com/linux/ubuntu  $(lsb_release -cs) stable"

apt-get update && apt-get install docker-ce

# 將使用者新增進docker 使普通使用者也可以使用docker命令
# docker 組存在也無所謂
sudo groupadd docker
# 新增使用者
sudo gpasswd -a ${USER} docker
# 這一步需要在root下
sudo chmod a+rw /var/run/docker.sock

# 啟動 Docker CE
systemctl enable docker
systemctl start docker
## 14.04
# service docker start

# 映象設定
mkdir -p /etc/docker && sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://yfexy6ee.mirror.aliyuncs.com"]
}
EOF
# 重啟
systemctl daemon-reload  && systemctl restart docker

多餘

## golang 環境的安裝 1.7及以上
apt-get install golang
# 沒有測試成功
# wget -c https://storage.googleapis.com/golang/go1.7.3.linux-amd64.tar.gz
# tar xf go1.7.3.linux-amd64.tar.gz
#

## flannel 安裝
# sudo yum install linux-libc-dev gcc
git clone https://github.com/coreos/flannel
cd flannel
make dist/flanneld-amd64

## 安裝 etcd
# git clone https://github.com/etcd-io/etcd.git
# cd etcd
# echo $GOPATH
# go get -v go.etcd.io/etcd
# ./build
curl -L https://github.com/etcd-io/etcd/releases/download/v3.3.10/etcd-v3.3.10-linux-amd64.tar.gz
tar xf etcd-v3.0.15-linux-amd64.tar.gz