docker基础及命令
1.启动docker
sudo systemctl start docker
sudo systemctl restart docker
sudo systemctl stop docker
sudo systemctl status docker
sudo docker info
Containers: 1
Running: 0
Paused: 0
Stopped: 1
Images: 2
Server Version: 17.03.1-ce
Storage Driver: devicemapper
Pool Name: vgdocker-thinpool
Pool Blocksize: 524.3 kB
Base Device Size: 10.74 GB
Backing Filesystem: xfs
Data file:
Metadata file:
Data Space Used: 2.708 GB
Data Space Total: 20.4 GB
Data Space Available: 17.69 GB
Metadata Space Used: 1.917 MB
Metadata Space Total: 213.9 MB
Metadata Space Available: 212 MB
Thin Pool Minimum Free Space: 2.039 GB
Udev Sync Supported: true
Deferred Removal Enabled: true
Deferred Deletion Enabled: true
Deferred Deleted Device Count: 0
Library Version: 1.02.135-RHEL7 (2016-11-16)
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 4ab9917febca54791c5f071a9d1f404867857fcc
runc version: 54296cf40ad8143b62dbcaa1d90e520a2136ddfe
init version: 949e6fa
Security Options:
seccomp
Profile: default
Kernel Version: 3.10.0-123.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 3.69 GiB
Name: wgl
ID: 2GXU:7CL7:ETAC:BTYX:M4V6:JSMV:3CIJ:4OZC:KKKX:D5IV:DVBX:T3KV
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
sudo docker run --name wgl_centos -i -t centos /bin/bash
sudo docker rename oldername newname
sudo docker ps -a #显示全部容器
sudo docker ps -l #列出最后一个运行的容器,也可以--format进一步控制显示
sudo docker ps -n x #显示最后x个容器。
sudo docker start(restart,stop) 容器ID(容器name)
sudo docker attach 容器
sudo docker run --name wgl_centos_daemon -d centos /bin/sh -c "while true;do echo hello world;sleep 3;done"
sudo docker logs 容器 #输出最后几条后返回
sudo docker logs -f 容器 #监控日志
sudo docker logs --tail 10 容器 #获取容器日志最后10条
sudo docker logs --tail 0 -f 容器 #跟踪最新日志
sudo docker logs -ft 容器 #监控日志+时间戳
sudo docker run --log-driver="syslog" --name wgl_centos_daemon -d centos /bin/sh -c "while true;do echo hello world;sleep 3;done"
sudo docker top wgl_centos_daemon
sudo docker stats [容器1 容器2 容器3 ...]
sudo docker exec -d 53fc4852ce08 touch /opt/wgl.log # -u 为新启动的进程指定属主
sudo docker exec -it 53fc4852ce08 /bin/bash
sudo docker run --restart=always --name wgl_centos_daemon -d centos /bin/sh -c "while true;do echo hello world;sleep 3;done"
sudo docker inspect 容器
[dwsoft@wgl ~]$ sudo docker inspect wgl_centos_daemon
[
{
"Id": "53fc4852ce081422068efa8bdcbad05d8b51b4fe2ba0a4389c91508dc3fbd50a",
"Created": "2017-05-28T05:35:00.155823247Z",
"Path": "/bin/sh",
"Args": [
"-c",
"while true;do echo hello world;sleep 3;done"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 6450,
"ExitCode": 0,
"Error": "",
"StartedAt": "2017-05-28T05:35:01.363485741Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "sha256:8140d0c64310d4e290bf3938757837dbb8f806acba0cb3f6a852558074345348",
"ResolvConfPath": "/var/lib/docker/containers/53fc4852ce081422068efa8bdcbad05d8b51b4fe2ba0a4389c91508dc3fbd50a/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/53fc4852ce081422068efa8bdcbad05d8b51b4fe2ba0a4389c91508dc3fbd50a/hostname",
"HostsPath": "/var/lib/docker/containers/53fc4852ce081422068efa8bdcbad05d8b51b4fe2ba0a4389c91508dc3fbd50a/hosts",
"LogPath": "/var/lib/docker/containers/53fc4852ce081422068efa8bdcbad05d8b51b4fe2ba0a4389c91508dc3fbd50a/53fc4852ce081422068efa8bdcbad05d8b51b4fe2ba0a
4389c91508dc3fbd50a-json.log", "Name": "/wgl_centos_daemon",
"RestartCount": 0,
"Driver": "devicemapper",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": null,
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "default",
"PortBindings": {},
"RestartPolicy": {
"Name": "no",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": null,
"CapAdd": null,
"CapDrop": null,
"Dns": [],
"DnsOptions": [],
"DnsSearch": [],
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "",
"Cgroup": "",
"Links": null,
"OomScoreAdj": 0,
"PidMode": "",
"Privileged": false,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"SecurityOpt": null,
"UTSMode": "",
"UsernsMode": "",
"ShmSize": 67108864,
"Runtime": "runc",
"ConsoleSize": [
0,
0
],
"Isolation": "",
"CpuShares": 0,
"Memory": 0,
"NanoCpus": 0,
"CgroupParent": "",
"BlkioWeight": 0,
"BlkioWeightDevice": null,
"BlkioDeviceReadBps": null,
"BlkioDeviceWriteBps": null,
"BlkioDeviceReadIOps": null,
"BlkioDeviceWriteIOps": null,
"CpuPeriod": 0,
"CpuQuota": 0,
"CpuRealtimePeriod": 0,
"CpuRealtimeRuntime": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": [],
"DiskQuota": 0,
"KernelMemory": 0,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": -1,
"OomKillDisable": false,
"PidsLimit": 0,
"Ulimits": null,
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0
},
"GraphDriver": {
"Name": "devicemapper",
"Data": {
"DeviceId": "76",
"DeviceName": "docker-253:1-277138-721bd5780ec0a2800c9db53413e77636e96e787a4b330b9d665c2cf289c01c43",
"DeviceSize": "10737418240"
}
},
"Mounts": [],
"Config": {
"Hostname": "53fc4852ce08",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Cmd": [
"/bin/sh",
"-c",
"while true;do echo hello world;sleep 3;done"
],
"Image": "centos",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": {
"build-date": "20170510",
"license": "GPLv2",
"name": "CentOS Base Image",
"vendor": "CentOS"
}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "dc56c0446f06b8b53b914574c34ec35c09fa38bc9d43d70ba5750aef60915597",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {},
"SandboxKey": "/var/run/docker/netns/dc56c0446f06",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "0da7299f69c100fce911e1c6b12f333e56ff30e3ff7a2f799ee595af89265fc8",
"Gateway": "172.17.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:11:00:02",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "23e919387bcf6493c7bdcd91e31b8995132fb7f081cfbac7778e855c6a4f6d58",
"EndpointID": "0da7299f69c100fce911e1c6b12f333e56ff30e3ff7a2f799ee595af89265fc8",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:02"
}
}
}
}
]
sudo docker rm 容器
sudo docker rm -f 容器 #删除正在运行的容器
- sudo docker rm `sudo docker ps -a -q` # -q只返回容器ID
docker基础及命令的更多相关文章
- docker基础维护命令
docker images显示当前存在的images docker ps,显示当前的container docker rm containerId 删除指定的container(需要先停止,才能删除) ...
- Docker - Docker基础命令及使用
Docker Docker - 官网 Docker - Hub GitHub - Docker Docker中文社区 Docker基础命令 Docker 查看帮助信息:docker --help 查看 ...
- 1. Docker基础命令
本文简要介绍Docker的基础命令,目的在于快速入门Dokcer,Docker的完整命令可以参考Docker官方手册. 0. 安装Docker Docker当前分为企业版(Docker Enterpr ...
- Docker基础修炼2--Docker镜像原理及常用命令
通过前文的讲解对Docker有了基本认识之后,我们开始进入实战操作,本文先演示Docker三要素之镜像原理和相关命令. 本文的演示环境仍然沿用上一篇文章在本地Centos7中安装的环境,如果你本地没有 ...
- docker基础命令和操作
前言 之前在部署个人网站的时候,需要打包maven,在生产环境,需要使用到docker去做服务器和端口的守护. 于是在查阅了相关资料,学习了docker一些基本命令行操作,包括对镜像的查看,修改和添加 ...
- docker基础命令,常用操作
docker基础命令 使用docker镜像 获取镜像 从docker registry获取镜像的命令是docker pull.命令格式是: docker pull [选项][docker regist ...
- Docker基础和常用命令
Docker基础和常用命令 一,Docker 简介 1.1,什么是 Docker Docker 使用 Google 公司推出的 Go 语言 进行开发实现,基于 Linux 内核的 cgroup,nam ...
- Docker 基础命令 简要入门
本文出自:http://www.cnblogs.com/scoter2008,本文将持续更新所有docker都可以通过man查看帮助:man docker [ps|top|run|...]1.列出正在 ...
- docker基础命令详解
Commands: attach Attach to a running container build Build an image from a Dockerfile commit ...
随机推荐
- JMM中的Happens-Before原则
在java内存模型中,happens-before应该理解为:前一个操作的结果,可以被后续的操作获取,即内存可见性. 为了解决多线程的内存可见性问题,就提出了happens-before原则, ...
- linux-head、tail、sort、uniq、pstree、ps
1.head 默认查看文件前10行 head -7 /etc/yum.conf -n num -n7代表查看文件前7行 2.tail 默认查看文件的后10行 tail -7 /etc/yum.conf ...
- vs2015编译zlib静态库步骤
ZLIB静态库的编译 下载ZLIB源码 ZLib官网下载或者GitHub上直接 clone 下来即可 www.zlib.net 截至目前最新版本1.2.1.1本 如下图我选择从官网下载 下载完以后解压 ...
- html页脚固定在底部的方法
<style type="text/css"> html { height: 100%; } body { height: 100%; margin: 0; paddi ...
- WIN10高清壁纸
下面给大家分享我自己收集的WIN10的壁纸(大家可以存在在自己网盘里) 百度网盘下载 提取码:dsf5
- Asp.Net Core下的开源任务调度平台ScheduleMaster
从何说起 2017年初的时候,由于当时项目需要做了一个乞丐版定时调度系统,那时候只在单机上实现了核心的调度功能.做这个玩意之前也调研了社区中开源的解决方案,找了几个实地部署试跑了一下,其实都很不错.但 ...
- MapGIS文件如何压缩存盘
经过多次编辑修改的MapGIS数据,含有大量逻辑上已删除的节点或图元,数据冗余复杂, 在转换过程前应注意一定要采用压缩存盘方式处理,目的是确保编辑状态已删除的数据真正从物理存储层删除,以确保数据的精简 ...
- acmPush模块示例demo
感谢论坛版主 马浩川 的分享. 模块介绍: 阿里移动推送(Alibaba Cloud Mobile Push)是基于大数据的移动智能推送服务,帮助App快速集成移动推送的功能,在实现高效.精确.实时 ...
- springcloud之断路器(Hystrix)
在微服务架构中,根据业务来拆分成一个个的服务,服务与服务之间可以相互调用(RPC),在Spring Cloud可以用RestTemplate+Ribbon和Feign来调用.为了保证其高可用,单个服务 ...
- 安装dbeaver,The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone.
在连接mysql时,出现了以下错误: 解决方法是 在数据库链接指定useUnicode=true&useSSL=false&characterEncoding=utf8&ser ...