阿里雲ECS # uname -r 4.4.162-1.el7.elrepo.x86_64 # cat /etc/centos-release CentOS Linux release 7.5.1804 (Core) # rpm -qa |grep kernel kernel-lt-tools-libs-4.4.162-1.el7.elrepo.x86_64 kernel-lt-4.4.162-1.el7.elrepo.x86_64 kernel-lt-headers-4.4.162-1.el7.elrepo.x86_64 kernel-lt-devel-4.4.162-1.el7.elrepo.x86_64 kernel-lt-tools-4.4.162-1.el7.elrepo.x86_64
官方文檔有詳細操做,能夠參考 https://docs.docker.com/install/linux/docker-ce/centos/
若是有舊版本docker,請使用如下指令卸載 # yum remove docker \ docker-client \ docker-client-latest \ docker-common \ docker-latest \ docker-latest-logrotate \ docker-logrotate \ docker-selinux \ docker-engine-selinux \ docker-engine
# yum install yum-utils device-mapper-persistent-data lvm2
Docker CE有兩種版本: edge 版本每個月發佈一次,主要面向那些喜歡嘗試新功能的用戶。 stable 版本每3個月發佈一次,維護期4個月。適用於但願更加容易維護的用戶(穩定版)。 edge版本 只能在當前月份得到安全和錯誤修復。 stable版 在初始發佈後4個月內接收關鍵錯誤修復和安全問題的修補程序。 Docker EE和stable版本的版本號保持一致。CE版並不是閹割版,而是改了個名稱;EE版則提供了一些收費的高級特性。
stable 版本 # yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo edge 版本 若是須要edge版本的docker,在上一條指令成功後啓用下面一行命令 # yum-config-manager --enable docker-ce-edge
# yum install docker-ce
列出版本 # yum list docker-ce --showduplicates | sort -r * elrepo: mirrors.tuna.tsinghua.edu.cn docker-ce.x86_64 18.06.1.ce-3.el7 docker-ce-stable docker-ce.x86_64 18.06.0.ce-3.el7 docker-ce-stable docker-ce.x86_64 18.03.1.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 18.03.0.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.12.1.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.12.0.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.09.1.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.09.0.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.06.2.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.06.1.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.06.0.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.03.3.ce-1.el7 docker-ce-stable docker-ce.x86_64 17.03.2.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.03.1.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.03.0.ce-1.el7.centos docker-ce-stable Available Packages 語法 yum install docker-ce-<版本號> 示例: # yum install docker-ce-17.12.0.ce-1.el7.centos # yum install docker-ce-18.06.1.ce-3.el7
在國內下載比較快python
Docker 官方中國區 https://registry.docker-cn.com 網易 http://hub-mirror.c.163.com 中國科學技術大學 https://docker.mirrors.ustc.edu.cn 阿里雲 https://dev.aliyun.com/ 註冊登錄帳號後,左邊菜單選 > 鏡像加速器 > 獲取到如下累似地址(固然,你也能夠直接使用個人) https://314lfirc.mirror.aliyuncs.com
最新版本的docker官方建議使用json格式修改linux
# vim /etc/docker/daemon.json { "registry-mirrors": ["https://314lfirc.mirror.aliyuncs.com"], "live-restore": true, "default-shm-size": "128M", "max-concurrent-downloads": 10, "oom-score-adjust": -1000, "debug": false }
# systemctl start docker # systemctl enable docker
方法一: # docker version Client: Version: 18.06.1-ce API version: 1.38 Go version: go1.10.3 Git commit: e68fc7a Built: Tue Aug 21 17:23:03 2018 OS/Arch: linux/amd64 Experimental: false Server: Engine: Version: 18.06.1-ce API version: 1.38 (minimum version 1.12) Go version: go1.10.3 Git commit: e68fc7a Built: Tue Aug 21 17:25:29 2018 OS/Arch: linux/amd64 Experimental: false 方法二: # docker info 會出現相似下面的相關信息 #docker info Containers: 0 Running: 0 Paused: 0 Stopped: 0 Images: 0 Server Version: 18.06.1-ce Storage Driver: overlay2 Backing Filesystem: extfs Supports d_type: true Native Overlay Diff: true Logging Driver: json-file Cgroup Driver: cgroupfs Plugins: Volume: local Network: bridge host macvlan null overlay Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog Swarm: inactive Runtimes: runc Default Runtime: runc Init Binary: docker-init containerd version: 468a545b9edcd5932818eb9de8e72413e616e86e runc version: 69663f0bd4b60df09991c08812a60108003fa340 init version: fec3683 Security Options: seccomp Profile: default Kernel Version: 4.4.162-1.el7.elrepo.x86_64 Operating System: CentOS Linux 7 (Core) OSType: linux Architecture: x86_64 CPUs: 1 Total Memory: 3.859GiB Name: jumpserver01 ID: 7V2P:3XOE:7IZD:V5FH:5IME:WMQ6:CGJH:7A3Y:7SUM:RKPJ:27C6:34GY Docker Root Dir: /var/lib/docker Debug Mode (client): false Debug Mode (server): false Registry: https://index.docker.io/v1/ Labels: Experimental: false Insecure Registries: 127.0.0.0/8 Registry Mirrors: https://314lfirc.mirror.aliyuncs.com/ > 這裏是添加的加速器 Live Restore Enabled: true 方法三: 經過運行hello-world 映像驗證是否已正確安裝, # docker run hello-world Hello from Docker! This message shows that your installation appears to be working correctly. To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. (amd64) 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal. To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash Share images, automate workflows, and more with a free Docker ID: https://hub.docker.com/ For more examples and ideas, visit: https://docs.docker.com/get-started/
1. 安裝docker-compose # pip install docker-compose # pip install --upgrade pip 這一行指令是升級pip版本的,按需。 2.找到對應當前compose版本號的命令補全 # docker-compose version /usr/lib/python2.7/site-packages/requests/__init__.py:80: RequestsDependencyWarning: urllib3 (1.22) or chardet (2.2.1) doesn't match a supported version! RequestsDependencyWarning) docker-compose version 1.23.1, build b02f130 此次安裝的版本號是1.23.1 docker-py version: 3.5.1 CPython version: 2.7.5 OpenSSL version: OpenSSL 1.0.2k-fips 26 Jan 2017 有留意到吧,查看 docker-compose 的version時報不兼容的問題 解決它: # pip uninstall urllib3 chardet Uninstalling chardet-3.0.4: Would remove: /usr/bin/chardetect /usr/lib/python2.7/site-packages/chardet-3.0.4.dist-info/* /usr/lib/python2.7/site-packages/chardet/* Would not remove (might be manually added): /usr/lib/python2.7/site-packages/chardet/chardetect.py /usr/lib/python2.7/site-packages/chardet/chardetect.pyo /usr/lib/python2.7/site-packages/chardet/constants.py /usr/lib/python2.7/site-packages/chardet/constants.pyo Proceed (y/n)? y Successfully uninstalled chardet-3.0.4 Uninstalling urllib3-1.22: Would remove: /usr/lib/python2.7/site-packages/urllib3-1.22.dist-info/* /usr/lib/python2.7/site-packages/urllib3/* Proceed (y/n)? y Successfully uninstalled urllib3-1.22 從新安裝 # pip install requests Successfully installed chardet-3.0.4 urllib3-1.22 再執行就沒問題了 # docker-compose version docker-compose version 1.23.1, build b02f130 docker-py version: 3.5.1 CPython version: 2.7.5 OpenSSL version: OpenSSL 1.0.2k-fips 26 Jan 2017 3. 去https://github.com/docker/compose/ 找到對應docker-compose版本的命令補全包 點開 Branch:master 邊上的小倒三角,選Tags ,點中你的版本號 進入如下目錄 compose/contrib/completion/這裏是你喜歡的shell類型/docker-compose 點開這個文件,對着Raw複製下載地址(不然不對) 下載到系統中, wget -O/etc/bash_completion.d/docker-compose \ https://raw.githubusercontent.com/docker/compose/1.23.1/contrib/completion/bash/docker-compose 生效當前shell # exec bash
在安裝docker時,默認已經建立了docker用戶組,該docker組授予與root 用戶等效的權限。 # useradd -g docker docker # passwd docker 設置這個普通用戶密碼 註銷並從新登陸,以便從新評估您的組成員身份。 若是在虛擬機上進行測試,則可能須要從新啓動虛擬機才能使更改生效。 $ docker run hello-world 此命令下載測試映像並在容器中運行它。當容器運行時,它會打印一條信息性消息並退出 Hello from Docker! This message shows that your installation appears to be working correctly. To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. (amd64) 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal.