Docker 是一個開源的應用容器引擎,讓開發者能夠打包他們的應用以及依賴包到一個可移植的鏡像中,而後發佈到任何流行的 Linux或Windows 機器上,也能夠實現虛擬化。容器是徹底使用沙箱機制,相互之間不會有任何接口。html
Docker 是 DevOps 的重要一個組成部分,不可缺乏,能夠說雲計算沒法離開docker,或者說沒法離開容器,容器已經成爲雲計算的重要基礎設施。node
Docker 是基於Linux 內核的一種虛擬化容器(Container),主要用到 CGroups,Namespace(ipc,network, user,pid,mount),UnionFileSystem 等技術封裝成一種自定義的容器格式,用於提供一整套虛擬運行環境。python
利用Docker容器技術,開發人員&運維 能夠快速的對應用程序進行「集裝箱化」封裝,隨時部署、分發應用程序,免去了傳統運維帶來的複雜性、不可控、結果不一致等問題。linux
靈活:即便是複雜的應用程序也可封裝。
輕量級:容器利用並共享主機內核。
便攜式:您能夠在本地構建,部署到雲上並在任何地方運行。
可擴展性:您能夠增長和自動分發容器副本。
可堆疊:您能夠垂直堆疊服務並及時並及時堆疊服務。docker
VM(VMware)在宿主機的硬件和操做系統基礎上構建虛擬機,虛擬機會佔用較多的CPU資源及內存,數據重量級的虛擬化,對於雲計算而言最大的弊端就是啓動緩慢,如須要啓動突發實例,啓動時間會很長,沒法快速響應express
Docker容器是共享操做系統內核,屬於輕量級虛擬化技術,容器自己的資源開銷極低,容器的啓動也很是快(秒級)npm
Daemon :Docker進程守護 ,負責後臺進程管理,鏡像管理,容器管理以及數據卷json
Client : 用於與Docker Daemon交互ubuntu
Image :Docker容器運行的鏡像文件,一般是一個linux系統,裏面包含一個或多個可運行的服務,例如Nginx、Tomcat、Spring Boot 等。api
Services :服務是docker swarm引入的概念,能夠在多宿主機之間伸縮容器數目,支持負載均衡已經服務路由功能。
更新安裝源
apt-get update apt-get install -y apt-transport-https gnupg-agent software-properties-common
添加阿里雲安裝源的密鑰
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add - apt-get update apt-get install -y apt-transport-https gnupg-agent software-properties-common
添加阿里雲安裝源
add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
安裝最新版 docker engine
apt update apt install docker-ce
配置 docker 加速鏡像
cat <<EOF > /etc/docker/daemon.json { "registry-mirrors": [ "https://a35khyup.mirror.aliyuncs.com" ], "exec-opts": [ "native.cgroupdriver=systemd" ] } EOF
重啓 docker
service docker restart
@查看docker 命令集
docker
@輸出---------------------------------------------------------------------------------------------------------------------------------- Usage: docker [OPTIONS] COMMAND A self-sufficient runtime for containers Options: --config string Location of client config files (default "/root/.docker") -c, --context string Name of the context to use to connect to the daemon (overrides DOCKER_HOST env var and default context set with "docker context use") -D, --debug Enable debug mode -H, --host list Daemon socket(s) to connect to -l, --log-level string Set the logging level ("debug"|"info"|"warn"|"error"|"fatal") (default "info") --tls Use TLS; implied by --tlsverify --tlscacert string Trust certs signed only by this CA (default "/root/.docker/ca.pem") --tlscert string Path to TLS certificate file (default "/root/.docker/cert.pem") --tlskey string Path to TLS key file (default "/root/.docker/key.pem") --tlsverify Use TLS and verify the remote -v, --version Print version information and quit Management Commands: builder Manage builds config Manage Docker configs container Manage containers context Manage contexts engine Manage the docker engine image Manage images network Manage networks node Manage Swarm nodes plugin Manage plugins secret Manage Docker secrets service Manage services stack Manage Docker stacks swarm Manage Swarm system Manage Docker trust Manage trust on Docker images volume Manage volumes Commands: attach Attach local standard input, output, and error streams to a running container build Build an image from a Dockerfile commit Create a new image from a container's changes cp Copy files/folders between a container and the local filesystem create Create a new container diff Inspect changes to files or directories on a container's filesystem events Get real time events from the server exec Run a command in a running container export Export a container's filesystem as a tar archive history Show the history of an image images List images import Import the contents from a tarball to create a filesystem image info Display system-wide information inspect Return low-level information on Docker objects kill Kill one or more running containers load Load an image from a tar archive or STDIN login Log in to a Docker registry logout Log out from a Docker registry logs Fetch the logs of a container pause Pause all processes within one or more containers port List port mappings or a specific mapping for the container ps List containers pull Pull an image or a repository from a registry push Push an image or a repository to a registry rename Rename a container restart Restart one or more containers rm Remove one or more containers rmi Remove one or more images run Run a command in a new container save Save one or more images to a tar archive (streamed to STDOUT by default) search Search the Docker