docker常用命令操作方法

2020-06-17 07:04:45易采站长站整理

然后用xattr -r -d 详细信息 * 去掉这些特殊权限(参考下图),然后再重新挂到容器中,就能正常使用了

其三:

mac上挂载的本机目录,必须是在~/(即:当前用户的目录)下,类似/opt/www这样的目录,就算给它所有权限,挂到容器中后,也只能看到目录,读不到任何文件,centOS上没这问题。

此外,还可以用命令


docker inspect myubuntu

查看此时容器的所有状态,会看到一段长长的json输出,类似下面这样:


[
{
"Id": "21d15713166ae83b022eea8806bd466da9917422e487e874cc098a0f1329dd48",
"Created": "2016-01-28T02:23:43.91086474Z",
"Path": "/bin/bash",
"Args": [],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 1843,
"ExitCode": 0,
"Error": "",
"StartedAt": "2016-01-28T02:26:09.414485616Z",
"FinishedAt": "2016-01-28T02:25:43.868883111Z"
},
"Image": "8693db7e8a0084b8aacba184cfc4ff9891924ed2270c6dec6a9d99bdcff0d1aa",
"ResolvConfPath": "/mnt/sda1/var/lib/docker/containers/21d15713166ae83b022eea8806bd466da9917422e487e874cc098a0f1329dd48/resolv.conf",
"HostnamePath": "/mnt/sda1/var/lib/docker/containers/21d15713166ae83b022eea8806bd466da9917422e487e874cc098a0f1329dd48/hostname",
"HostsPath": "/mnt/sda1/var/lib/docker/containers/21d15713166ae83b022eea8806bd466da9917422e487e874cc098a0f1329dd48/hosts",
"LogPath": "/mnt/sda1/var/lib/docker/containers/21d15713166ae83b022eea8806bd466da9917422e487e874cc098a0f1329dd48/21d15713166ae83b022eea8806bd466da9917422e487e874cc098a0f1329dd48-json.log",
"Name": "/myubuntu",
"RestartCount": 0,
"Driver": "aufs",
"ExecDriver": "native-0.2",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": [
"/Users/yjmyzz/docker_volumn:/opt/webapp"
],
"ContainerIDFile": "",
"LxcConf": [],
"Memory": 0,
"MemoryReservation": 0,
"MemorySwap": 0,
"KernelMemory": 0,
"CpuShares": 0,
"CpuPeriod": 0,
"CpusetCpus": "",
"CpusetMems": "",
"CpuQuota": 0,
"BlkioWeight": 0,
"OomKillDisable": false,
"MemorySwappiness": -1,
"Privileged": false,
"PortBindings": {},
"Links": null,
"PublishAllPorts": false,
"Dns": [],
"DnsOptions": [],
"DnsSearch": [],
"ExtraHosts": null,
"VolumesFrom": null,
"Devices": [],
"NetworkMode": "default",
"IpcMode": "",
"PidMode": "",
"UTSMode": "",
"CapAdd": null,
"CapDrop": null,