本文主要講解在 Ubuntu 上安裝和配置 Docker CE。html
Ubuntu(烏班圖)是一個基於Debian的以桌面應用爲主的Linux操做系統,目標在於爲通常用戶提供一個最新同時又至關穩定,主要以自由軟件建構而成的操做系統。linux
Ubuntu官方網站: http://www.ubuntu.com/
這裏使用版本是:Ubuntu 16.04 LTS 桌面版git
使用 apt 管理安裝包
安裝完成後經過apt-get update更新程序。
Advanced Packaging Tool(apt)是一款安裝包管理工具。github
apt相關命令
sudo apt-get update //更新軟件信息數據庫 sudo apt-get install xxx //安裝xxx -d 僅下載 -f 強制安裝 sudo apt-get remove xxx //卸載xxx sudo apt-get upgrade //進行系統升級 sudo apt-cache search //搜索軟件包
apt代理設置
sudo touch /etc/apt/apt.conf //新建配置文件。 sudo gedit /etc/apt/apt.conf //修改配置文件加入:Acquire::http::Proxy "http://proxyusr:password@yourproxyaddress:proxyport";
建議您常常使用 sudo apt-get update 命令來更新您的軟件信息數據庫,並且每次修改了/etc/apt/sources.list 後,必須執行。docker
使用 SSH 遠程鏈接數據庫
安裝SSH Serverubuntu
sudo apt-get install openssh-server
開啓使用root賬號SSH登陸
Ubuntu默認是不啓用root用戶也不容許root遠程登陸的。安全
sudo passwd root //修改 root 密碼 啓用root帳戶 sudo vi /etc/ssh/sshd_config //修改配置文件PermitRootLogin prohibit-password -> PermitRootLogin yes sudo service ssh restart //重啓ssh
查看IP
ifconfig
工具
這裏使用WinSCP+Putty工具遠程操做系統。ssh
PuTTY - 一個免費的SSH和telnet客戶端工具
WinSCP - 一個免費開源的SFTP, SCP 和 FTP 客戶端工具
Docker 屬於 Linux 容器的一種封裝,提供簡單易用的容器使用接口。它是目前最流行的 Linux 容器解決方案。
Docker 將應用程序與該程序的依賴,打包在一個文件裏面。運行這個文件,就會生成一個虛擬容器。程序在這個虛擬容器裏運行,就好像在真實的物理機上運行同樣。有了 Docker,就不用擔憂環境問題。
整體來講,Docker 的接口至關簡單,用戶能夠方便地建立和使用容器,把本身的應用放入容器。容器還能夠進行版本管理、複製、分享、修改,就像管理普通的代碼同樣。
Docker的主要好處:
Docker官網:https://www.docker.com/
sudo apt-get remove docker docker-engine docker.io
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 - #若是使用代理請添加-x proxyaddress:proxyport
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 sudo apt-get install docker-ce
sudo systemctl enable docker sudo systemctl start docker
sudo mkdir -p /etc/systemd/system/docker.service.d //建立文件夾 sudo vi /etc/systemd/system/docker.service.d/http-proxy.conf //建立配置文件並添加下面兩行 [Service] Environment="HTTP_PROXY=http://proxy.example.com:80/" "NO_PROXY=localhost,127.0.0.1,docker-registry.somecorporation.com" sudo systemctl daemon-reload //刷新變化 sudo systemctl restart docker //重啓Docker
sudo groupadd docker //創建 docker 組 sudo usermod -aG docker $USER //將當前用戶加入 docker 組
docker run hello-world