简体   繁体   中英

Docker Container is disappeard after restart service

I stopped my docker container. and i restart the service in linux (service docker restart)

after that my container is missing. I typed docker ps -a but I can't find my splunk container.

I can find container directory and volume folder also. also I have every folder in inspection result. but I can't see when I type docker ps -a

how can I restore it ?

this is my docker inspect result, when container is exist.

    [
    {
        "Id": "9e12bb7b2f8a926c0b7852aa9f1bf957363f327d6de53778059bf0fc05711039",
        "Created": "2018-10-02T04:05:28.013507313Z",
        "Path": "/sbin/entrypoint.sh",
        "Args": [
            "start-service"
        ],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 11513,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2020-09-22T05:22:09.939497539Z",
            "FinishedAt": "2020-09-22T05:20:05.99542747Z"
        },
        "Image": "sha256:507021d7e77f9bdd337aeb47729a806162579f36e5d73b14f2a508e545adae72",
        "ResolvConfPath": "/storage/docker/containers/9e12bb7b2f8a926c0b7852aa9f1bf957363f327d6de53778059bf0fc05711039/resolv.conf",
        "HostnamePath": "/storage/docker/containers/9e12bb7b2f8a926c0b7852aa9f1bf957363f327d6de53778059bf0fc05711039/hostname",
        "HostsPath": "/storage/docker/containers/9e12bb7b2f8a926c0b7852aa9f1bf957363f327d6de53778059bf0fc05711039/hosts",
        "LogPath": "/storage/docker/containers/9e12bb7b2f8a926c0b7852aa9f1bf957363f327d6de53778059bf0fc05711039/9e12bb7b2f8a926c0b7852aa9f1bf957363f327d6de53778059bf0fc05711039-json.log",
        "Name": "/splunk",
        "RestartCount": 0,
        "Driver": "overlay",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "",
        "ExecIDs": null,
        "HostConfig": {
            "Binds": null,
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "json-file",
                "Config": {}
            },
            "NetworkMode": "default",
            "PortBindings": {
                "8000/tcp": [
                    {
                        "HostIp": "",
                        "HostPort": "8000"
                    }
                ],
                "8089/tcp": [
                    {
                        "HostIp": "",
                        "HostPort": "8089"
                    }
                ]
            },
            "RestartPolicy": {
                "Name": "unless-stopped",
                "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": [],
            "DeviceCgroupRules": null,
            "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": {
            "Data": {
                "LowerDir": "/storage/docker/overlay/25444b7c23c5d0bf0a6d4d1563a587831b7c329e6623ee720e609a0a16787ef5/root",
                "MergedDir": "/storage/docker/overlay/53d6023089444b76af280ef1220a2851c1b5045167c471f5f60f9faa0389ccd3/merged",
                "UpperDir": "/storage/docker/overlay/53d6023089444b76af280ef1220a2851c1b5045167c471f5f60f9faa0389ccd3/upper",
                "WorkDir": "/storage/docker/overlay/53d6023089444b76af280ef1220a2851c1b5045167c471f5f60f9faa0389ccd3/work"
            },
            "Name": "overlay"
        },
        "Mounts": [
            {
                "Type": "volume",
                "Name": "cb9d0886db87a17304310bfa5a242972bf9c76464eb0c85c24902c7764443714",
                "Source": "/storage/docker/volumes/cb9d0886db87a17304310bfa5a242972bf9c76464eb0c85c24902c7764443714/_data",
                "Destination": "/opt/splunk/etc",
                "Driver": "local",
                "Mode": "",
                "RW": true,
                "Propagation": ""
            },
            {
                "Type": "volume",
                "Name": "5d637a70101b4d6a80261abfeac9534b8b77bde4669c6225dedf3a9bcfb4434a",
                "Source": "/storage/docker/volumes/5d637a70101b4d6a80261abfeac9534b8b77bde4669c6225dedf3a9bcfb4434a/_data",
                "Destination": "/opt/splunk/var",
                "Driver": "local",
                "Mode": "",
                "RW": true,
                "Propagation": ""
            }
        ],
        "Config": {
            "Hostname": "9e12bb7b2f8a",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "1514/tcp": {},
                "8000/tcp": {},
                "8088/tcp": {},
                "8089/tcp": {},
                "8191/tcp": {},
                "9997/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "SPLUNK_START_ARGS=--accept-license",
                "SPLUNK_USER=root",
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "SPLUNK_PRODUCT=splunk",
                "SPLUNK_VERSION=7.0.0",
                "SPLUNK_BUILD=c8a78efdd40f",
                "SPLUNK_FILENAME=splunk-7.0.0-c8a78efdd40f-Linux-x86_64.tgz",
                "SPLUNK_HOME=/opt/splunk",
                "SPLUNK_APPS=/opt/splunk/etc/apps",
                "SPLUNK_GROUP=splunk",
                "SPLUNK_BACKUP_DEFAULT_ETC=/var/opt/splunk",
                "LANG=en_US.utf8",
                "JAVA_HOME=/opt/jdk/jdk1.8.0_152/"
            ],
            "Cmd": [
                "start-service"
            ],
            "ArgsEscaped": true,
            "Image": "klustree/splunk:7.0.0",
            "Volumes": {
                "/opt/splunk/etc": {},
                "/opt/splunk/var": {}
            },
            "WorkingDir": "/opt/splunk",
            "Entrypoint": [
                "/sbin/entrypoint.sh"
            ],
            "OnBuild": null,
            "Labels": {}
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "57cf9a7d9ec5d31e685fd5ea9232a3126fab1a90406449cc4d48b43a2f7c4f57",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {
                "1514/tcp": null,
                "8000/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "8000"
                    }
                ],
                "8088/tcp": null,
                "8089/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "8089"
                    }
                ],
                "8191/tcp": null,
                "9997/tcp": null
            },
            "SandboxKey": "/var/run/docker/netns/57cf9a7d9ec5",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "b4d39d4b6615127cd6aaeda1e0e14e73d910fadf9b596d5b81698d3fc1c53945",
            "Gateway": "172.17.1.1",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "172.17.1.4",
            "IPPrefixLen": 24,
            "IPv6Gateway": "",
            "MacAddress": "02:42:ac:11:01:04",
            "Networks": {
                "bridge": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": null,
                    "NetworkID": "c563f5e5d0e2e4bd6d35f5802395f77874679e40a522dabaee59b93d3747619c",
                    "EndpointID": "b4d39d4b6615127cd6aaeda1e0e14e73d910fadf9b596d5b81698d3fc1c53945",
                    "Gateway": "172.17.1.1",
                    "IPAddress": "172.17.1.4",
                    "IPPrefixLen": 24,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:ac:11:01:04",
                    "DriverOpts": null
                }
            }
        }
    }
]

please help...

This is the default behavior of the docker service, in the docs we learn:

By default, when the Docker daemon terminates, it shuts down running containers. Starting with Docker Engine 1.12, you can configure the daemon so that containers remain running if the daemon becomes unavailable. This functionality is called live restore. The live restore option helps reduce container downtime due to daemon crashes, planned outages, or upgrades.

Here you can learn how to keep your containers alive when occurring a service timeout.

And here you can configure for your containers still alive when the docker service is restarted.

Although live-restore and the restart policy might seem similar they have different purposes:

Restart policies are different from the --live-restore flag of the dockerd command. Using --live-restore allows you to keep your containers running during a Docker upgrade, though networking and user input are interrupted.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM