Docker的有关命令(英文看不懂看下面对应中文)
Management Commands:
container Manage containers
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
volume Manage volumes
Commands:
attach Attach 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 Hub for images
start Start one or more stopped containers
stats Display a live stream of container(s) resource usage statistics
stop Stop one or more running containers
tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
top Display the running processes of a container
unpause Unpause all processes within one or more containers
update Update configuration of one or more containers
version Show the Docker version information
wait Block until one or more containers stop, then print their exit codes
Docker的有关命令(中文版)
管理命令:
容器管理的容器
图像处理图像
网络管理网络
节点管理群节点
插件管理插件
秘密管理码头工人的秘密
服务管理服务
栈码头工人管理栈
群管理群
系统管理码头工人
卷管理卷
命令:
连接到正在运行的容器上
从Dockerfile构建一个映像
commit从容器的更改创建新映像
cp在容器和本地文件系统之间复制文件/文件夹
创建一个新容器
diff检查对容器文件系统上的文件或目录的更改
事件从服务器获得实时事件
exec在正在运行的容器中运行命令
导出将容器的文件系统导出为tar存档文件
历史展示了一个形象的历史
图像列表图片
从tarball中导入内容以创建文件系统映像
信息显示系统信息
检查返回Docker对象的低级信息
杀死一个或多个正在运行的容器
从tar存档或STDIN加载图像
登录到Docker注册表
从Docker注册表注销
获取容器的日志
暂停一个或多个容器中的所有进程
端口列表端口映射或容器的特定映射
ps列表容器
从注册表中提取图像或存储库
将映像或存储库推到注册表
重命名重命名一个容器
重新启动一个或多个容器
rm移走一个或多个容器
rmi删除一个或多个图像
在新容器中运行命令
保存一个或多个图像到tar存档(默认为STDOUT流媒体格式)
搜索Docker中心的图片
开始启动一个或多个已停止的容器
stats显示容器资源使用统计信息的实时流
停止一个或多个正在运行的容器
创建一个引用SOURCE_IMAGE的标签TARGET_IMAGE
顶部显示一个容器的运行进程
一个或多个容器中的所有进程
更新一个或多个容器的更新配置
版本显示Docker版本信息
等待块直到一个或多个容器停止,然后打印它们的退出码
用docker玩转game2048
需要下载docker的包
get docker-engine-17.03.1.ce-1.el7.centos.x86_64.rpm
get docker-engine-selinux-17.03.1.ce-1.el7.centos.noarch.rpm
#必须用7.3版本yum安装 其他版本要解决依赖性
查看版本信息
[root@foundation20 ~]# docker version
Client:
Version: 17.03.1-ce
API version: 1.27
Go version: go1.7.5
Git commit: c6d412e
Built: Fri Mar 24 00:36:45 2017
OS/Arch: linux/amd64
Server:
Version: 17.03.1-ce
API version: 1.27 (minimum version 1.12)
Go version: go1.7.5
Git commit: c6d412e
Built: Fri Mar 24 00:36:45 2017
OS/Arch: linux/amd64
Experimental: false
##导入镜像
[root@foundation20 ~]# docker load -i game2048.tar
Loaded image: game2048:latest
##将game2048加入到docker中 并更名vm2
[root@foundation20 ~]# docker run -d --name vm2 game2048
e9186ecbe917563ffb629a215264ad0f268d141651e7b70da1e6cf03690bba0b
查看ip 并且在真机上也可以看到加入的网关信息
[root@foundation20 ~]# docker inspect vm2
。。。。。。
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:02"
##加入的网关信息
9: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP
link/ether 02:42:56:bd:bc:9d brd ff:ff:ff:ff:ff:ff
inet 172.17.0.1/16 scope global docker0
valid_lft forever preferred_lft forever
inet6 fe80::42:56ff:febd:bc9d/64 scope link
valid_lft forever preferred_lft forever
。。。。。。
在web浏览器输入ipaddress
在docker容器上做nginx(nginx加速)
首先在官方镜像找到个人加速服务的地址
我这里用阿里云镜像www.aliyum.com
在真机上编写
[root@foundation20 ~]# cd /etc/docker/
[root@foundation20 docker]# ls
daemon.json key.json
[root@foundation20 docker]# cat daemon.json
{
"registry-mirrors": ["https://a16hm72u.mirror.aliyuncs.com"]
}
[root@foundation20 docker]#
从镜像下载nginx
[root@foundation20 docker]# docker run -d --name vm2 nginx
Unable to find image 'nginx:latest' locally
latest: Pulling from library/nginx
be8881be8156: Pull complete
32d9726baeef: Pull complete
87e5e6f71297: Pull complete
Digest: sha256:d85914d547a6c92faa39ce7058bd7529baacab7e0cd4255442b04577c4d1f424
Status: Downloaded newer image for nginx:latest
beea793aa0cf5c6a29331115d68b307989195712f23d4c5a5ea3702a4e38ca37
用docker ps -a 查看
[root@foundation20 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
beea793aa0cf nginx "nginx -g 'daemon ..." 7 minutes ago Up 7 minutes 80/tcp vm2
我们首先把nginx的默认发布目录编辑好
追加到docker容器里
在web浏览器查看
还有一种更方便的方法
把docker中的默认发布目录挂载到真机的指定目录下
然后编辑指定的目录
nginx出现的内容就是你指定的内容
在这里 我指定到/root目录下
[root@foundation20 ~]# docker run -d --name vm2 -v /root/:/usr/share/nginx/html nginx
##追加到docker容器
1189de09df56963c0e1c82954972985e2096aaaedd3bb03b5ed00d63e8531e2
成功后我在指定目录编写内容
在web浏览器查看