我在官方docker网站上遵循了“开始”教程,一切都很顺利,直到我尝试删除容器。每次当我运行时
docker rm -f [container_id]
或
docker stop -f [container_id]
具有该 ID 的初始容器将停止或删除,但新容器出现并运行。我试图使用以下命令更新容器:
docker update --restart=no $(docker ps -aq)
然而,这没有帮助。
这里是'docker info'命令结果:
$ docker info
Containers: 5
Running: 5
Paused: 0
Stopped: 0
Images: 1
Server Version: 17.05.0-ce
Storage Driver: aufs
Root Dir: /var/lib/docker/aufs
Backing Filesystem: extfs
Dirs: 22
Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Swarm: active
NodeID: qpmjeqewpl5hnneuhm99dp7g7
Is Manager: true
ClusterID: x14jwe053zapko55g7edlh9fp
Managers: 1
Nodes: 1
Orchestration:
Task History Retention Limit: 5
Raft:
Snapshot Interval: 10000
Number of Old Snapshots to Retain: 0
Heartbeat Tick: 1
Election Tick: 3
Dispatcher:
Heartbeat Period: 5 seconds
CA Configuration:
Expiry Duration: 3 months
Node Address: 192.168.0.108
Manager Addresses:
192.168.0.108:2377
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 9048e5e50717ea4497b757314bad98ea3763c145
runc version: 9c2d8d184e5da67c95d601382adf14862e4f2228
init version: 949e6fa
Security Options:
apparmor
seccomp
Profile: default
Kernel Version: 4.10.0-28-generic
Operating System: Ubuntu 16.04.2 LTS
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 5.74GiB
Name: roman-LIFEBOOK-AH531
ID: BHNU:2PGO:UDAA:MFYE:XGLO:R4PS:27QR:GXF6:KZME:W4EN:C5VO:FIJM
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Username: rmcontkit
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
和“docker inspect[container_id]”
$ docker inspect f53643ac5f9b
[
{
"Id": "f53643ac5f9b105c6b0d09de43eecd01f9d8bc3a20c71a535c1a25818db64775",
"Created": "2017-07-30T15:03:23.009739796Z",
"Path": "python",
"Args": [
"app.py"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 10661,
"ExitCode": 0,
"Error": "",
"StartedAt": "2017-07-30T15:03:30.614115776Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "sha256:413941614a833af57c05119d70cae063e0dc164b919e8ec84c6af595e7225b85",
"ResolvConfPath": "/var/lib/docker/containers/f53643ac5f9b105c6b0d09de43eecd01f9d8bc3a20c71a535c1a25818db64775/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/f53643ac5f9b105c6b0d09de43eecd01f9d8bc3a20c71a535c1a25818db64775/hostname",
"HostsPath": "/var/lib/docker/containers/f53643ac5f9b105c6b0d09de43eecd01f9d8bc3a20c71a535c1a25818db64775/hosts",
"LogPath": "/var/lib/docker/containers/f53643ac5f9b105c6b0d09de43eecd01f9d8bc3a20c71a535c1a25818db64775/f53643ac5f9b105c6b0d09de43eecd01f9d8bc3a20c71a535c1a25818db64775-json.log",
"Name": "/getstartedlab_web.2.yr7k0egu4ketu7m0kdxt7v3o7",
"RestartCount": 0,
"Driver": "aufs",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "docker-default",
"ExecIDs": null,
"HostConfig": {
"Binds": null,
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "default",
"PortBindings": {},
"RestartPolicy": {
"Name": "",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": null,
"CapAdd": null,
"CapDrop": null,
"Dns": null,
"DnsOptions": null,
"DnsSearch": null,
"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": 52428800,
"NanoCpus": 0,
"CgroupParent": "",
"BlkioWeight": 0,
"BlkioWeightDevice": null,
"BlkioDeviceReadBps": null,
"BlkioDeviceWriteBps": null,
"BlkioDeviceReadIOps": null,
"BlkioDeviceWriteIOps": null,
"CpuPeriod": 100000,
"CpuQuota": 10000,
"CpuRealtimePeriod": 0,
"CpuRealtimeRuntime": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": null,
"DeviceCgroupRules": null,
"DiskQuota": 0,
"KernelMemory": 0,
"MemoryReservation": 0,
"MemorySwap": -1,
"MemorySwappiness": -1,
"OomKillDisable": false,
"PidsLimit": 0,
"Ulimits": null,
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0
},
"GraphDriver": {
"Data": null,
"Name": "aufs"
},
"Mounts": [],
"Config": {
"Hostname": "f53643ac5f9b",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"80/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"LANG=C.UTF-8",
"GPG_KEY=C01E1CAD5EA2C4F0B8E3571504C367C218ADD4FF",
"PYTHON_VERSION=2.7.13",
"PYTHON_PIP_VERSION=9.0.1",
"NAME=World"
],
"Cmd": [
"python",
"app.py"
],
"ArgsEscaped": true,
"Image": "rmcontkit/get-started:part1@sha256:e7c1e776eb3eca11213449a8621cc84f989cb127350c3207ae8c610d482c0398",
"Volumes": null,
"WorkingDir": "/app",
"Entrypoint": null,
"OnBuild": null,
"Labels": {
"com.docker.stack.namespace": "getstartedlab",
"com.docker.swarm.node.id": "qpmjeqewpl5hnneuhm99dp7g7",
"com.docker.swarm.service.id": "8dj5jmxiqcip81ay1we2yd8uc",
"com.docker.swarm.service.name": "getstartedlab_web",
"com.docker.swarm.task": "",
"com.docker.swarm.task.id": "yr7k0egu4ketu7m0kdxt7v3o7",
"com.docker.swarm.task.name": "getstartedlab_web.2.yr7k0egu4ketu7m0kdxt7v3o7"
}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "e6d8f06b6ca25b73c100921213fe47dd4fc93eaf95db09be2dc0191b989aa139",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"80/tcp": null
},
"SandboxKey": "/var/run/docker/netns/e6d8f06b6ca2",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "",
"Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"MacAddress": "",
"Networks": {
"getstartedlab_webnet": {
"IPAMConfig": {
"IPv4Address": "10.0.0.7"
},
"Links": null,
"Aliases": [
"f53643ac5f9b"
],
"NetworkID": "k3as780fjdoywrdxdiabned7u",
"EndpointID": "44933d5909d3ff46c34e9a28317d5eaf025497ab61b951dbf054853415634c6e",
"Gateway": "",
"IPAddress": "10.0.0.7",
"IPPrefixLen": 24,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:0a:00:00:07"
},
"ingress": {
"IPAMConfig": {
"IPv4Address": "10.255.0.8"
},
"Links": null,
"Aliases": [
"f53643ac5f9b"
],
"NetworkID": "6um0tpqyj5pkl12xzklmt7vdv",
"EndpointID": "20a9ac122ba2cdcda5827b2d54688426d1df0dafa20afa70bf8f65b387d07b77",
"Gateway": "",
"IPAddress": "10.255.0.8",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:0a:ff:00:08"
}
}
}
}
]
问题内容: 尝试停止或重新启动Docker容器时,我收到以下错误消息: 但是当我跑步时 我可以看到日志,因此显然容器确实存在。有任何想法吗? 编辑: 抱歉,我忘了提一下: 运行时,我看到容器已启动并正在运行。但是,其中的应用程序出现故障,因此我想重新启动它,或者只是在线获取该应用程序的新版本。但是,当我无法停止并删除容器时,也无法启动并运行要监听同一端口的新应用程序。 问题答案: 看起来像dock
尝试停止或重新启动docker容器时,我收到以下错误消息: 但当我跑的时候 我可以看到日志,所以很明显容器确实存在。有什么想法吗? 编辑: 对不起,我忘了提这个: 当我运行时,我看到容器已经启动并正在运行。但是其中的应用程序出现故障,所以我想重新启动它,或者只是在线获取该应用程序的新版本。但是当我无法停止并删除容器时,我也无法启动并运行一个新应用程序,这将监听相同的端口。
我在试着和孔在一起。我在AWS上运行这个。每当我停止服务器并启动它时,API和插件中的每个条目都会消失。所以在每次启动和停止之后,我必须重新添加api和插件的值。有人能告诉我如何保留数据吗? docker run-d--名为kong database-p9042:9042 cassandra:2.2然后我运行了kong docker run-d--名为kong--链接kong database:k
问题内容: 我使用以下命令从映像启动docker容器: 当完成后,容器停止(我想这已停止),但它并没有被删除,因为我可以用这个命令来查看它: 有什么办法可以使用相同的参数将此容器保持由生成的数据? 问题答案: 是的,当初始命令完成执行后,容器将停止。 您可以使用以下方法启动已停止的容器: 如果要查看命令的输出,则应添加选项: PS。有一个,但用于重新启动正在运行的容器-我相信情况并非如此。
根据我目前阅读的教程,使用“”将从图像启动一个容器,容器将在后台运行。这就是它的样子,我们可以看到我们已经有了容器id。 但如果我运行“”,则不会返回任何内容。 所以我尝试了“”,我可以看到容器已经退出: 我做错了什么吗?如何解决此问题?
问题内容: 是否有可以将and 命令组合在一起的命令?每次我要删除正在运行的容器时,都需要顺序执行2条命令,我想知道是否有组合的命令可以简化此过程。 问题答案: 您可以使用 : 即使容器仍在运行,它也会删除该容器。 https://docs.docker.com/engine/reference/commandline/rm/ 您也可以使用选项运行容器,停止后它将自动删除。 https://doc