方法一:
# 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/
docker-compose 命令补全
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 以非root用户身份管理Docker
在安装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.