当前位置: 首页 > 知识库问答 >
问题:

装载后未在主机上创建文件

申屠黎昕
2023-03-14

使用docker container inspect xxx,我可以找到装载信息。

"Mounts": [
        {
            "Type": "bind",
            "Source": "/deploy/app/log",
            "Destination": "/home/applog",
            "Mode": "",
            "RW": true,
            "Propagation": "rprivate"
        }
    ],

在docker exec-it xxx bash之后,就会出现部署/应用/日志目录,其中的文件也会更新
但是,主机上没有创建主/应用程序日志目录,我仔细检查了源代码是否正确,例如部署/应用程序/日志

这个问题与我的情况非常接近,因为讨论使用目录装载的答案可以解决这个问题,这意味着不是我的问题。Docker bind装载目录中的文件未更新

我的假设是关于写作特权。关于如何解决这种情况的问题,有什么想法吗?

参见Docker中运行/停止集装箱的完整命令Find(查找)命令

服务器正在使用CentOS。

[
    {
        "Id": "9b7127d72e8cdf42b7bf7ec1e6559d2d9c02eb0deb197375c084532a8e4f443c",
        "Created": "2018-11-15T09:22:42.498258742Z",
        "Path": "/usr/bin/supervisord",
        "Args": [],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 19508,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2019-02-19T08:17:25.738865995Z",
            "FinishedAt": "2019-02-19T08:17:25.484443245Z"
        },
        "Image": "sha256:02079d9230e89eeb1eb14d61ab299da9e0301abed90864655087a39c3010a222",
        "ResolvConfPath": "/var/lib/docker/containers/9b7127d72e8cdf42b7bf7ec1e6559d2d9c02eb0deb197375c084532a8e4f443c/resolv.conf",
        "HostnamePath": "/var/lib/docker/containers/9b7127d72e8cdf42b7bf7ec1e6559d2d9c02eb0deb197375c084532a8e4f443c/hostname",
        "HostsPath": "/var/lib/docker/containers/9b7127d72e8cdf42b7bf7ec1e6559d2d9c02eb0deb197375c084532a8e4f443c/hosts",
        "LogPath": "",
        "Name": "/prime",
        "RestartCount": 0,
        "Driver": "overlay2",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "",
        "ExecIDs": null,
        "HostConfig": {
            "Binds": [
                "/deploy/app/log/:/home/primelog/"
            ],
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "journald",
                "Config": {}
            },
            "NetworkMode": "isolated_nw",
            "PortBindings": {
                "5000/tcp": [
                    {
                        "HostIp": "",
                        "HostPort": "5000"
                    }
                ],
                "80/tcp": [
                    {
                        "HostIp": "",
                        "HostPort": "90"
                    }
                ]
            },
            "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": "docker-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": "overlay2",
            "Data": {
                "LowerDir": "/var/lib/docker/overlay2/705a362229df9caa92a7df72427890ea99ab01f04fc0d3056e55d50f69fe0214-init/diff:/var/lib/docker/overlay2/83e113da8135ee896fa64413cfbc5198c6414d556e002e5f5d398e3615683a0f/diff:/var/lib/docker/overlay2/334a1f552eb25e0fec63bf12e2c3a0cbf168b3ddee22c9349d935557b3ec1e40/diff:/var/lib/docker/overlay2/6745c1ba399830b8f2b8c4bcce5704093dab7342bb97e57ad6c7de666c2a7923/diff:/var/lib/docker/overlay2/a4721324b462df2f6197206ebd61c803f75ea1ea8d9a3a15d6876a4439c359c0/diff:/var/lib/docker/overlay2/4ab1ee75afa757ccba6d744c0b773e75e8d0d064f367496cc1dc9c140800303a/diff:/var/lib/docker/overlay2/ae19ae7d9c4878438bfe3d80c8a7be32304df2e9af95f851f1d5fa9636c555f5/diff:/var/lib/docker/overlay2/c01c124469518c189dd1384f81e7d887fa5ee5cd46c368b67fa75285fad61a7a/diff:/var/lib/docker/overlay2/3bdec856fe714fb865d6bdb3e2d2b5512aac8c5eed8c20c00416a92159b0469b/diff:/var/lib/docker/overlay2/ae4bdc4a37252da3326f81ed8536f4c536aa59d6b46a1e198893c0aa816a3bda/diff:/var/lib/docker/overlay2/ecab217632d4c34bbafb098755855d0f5861fd21a4df809f1c16081a08a33865/diff:/var/lib/docker/overlay2/c5958ffc7e373cf927b181010d3d40b2bac384f7d45253842dc7316022f4c8ff/diff:/var/lib/docker/overlay2/bd73e0cc649d72fcb1eaabf582ba948b34d5e91f43d1ce1a9dd54192beecde26/diff:/var/lib/docker/overlay2/3cfccc6f5782f0e83be600097aa6d9f0da0d2bd978ffd4f36c97060fad7352c8/diff:/var/lib/docker/overlay2/a0efa6e2c8dfa6529c1ce891406e5c3be1559809d05d0efafd789453615c2e50/diff:/var/lib/docker/overlay2/87959f4181e90b251956cf864095821dce34b8e4f925713c2de1e029e11c5b6b/diff:/var/lib/docker/overlay2/2fae884b115fe56f6e04de3df4391501d0bb694f2ec3b8c4189c5519642231e1/diff:/var/lib/docker/overlay2/ec08c775e3bf6968bb67bf7713313f7d9bad5c29dc49baddb623d5bc0c5218f6/diff:/var/lib/docker/overlay2/d37caccf87df38f4ffee6fcd9b96c81fd323d52e3a1eeb85d75babf9f0b59ac6/diff:/var/lib/docker/overlay2/6f7c20c7f13cc18c86de6f7c8f574a2a123b06e0e1f65a18eca7981e601ed819/diff:/var/lib/docker/overlay2/2055cc3e03990255615e9843b9e5df2e5a9d5fd44b65bc83fc867611bd67a538/diff:/var/lib/docker/overlay2/913548c1650469d344bbe8eb41a824669b6665c2aa8c2ac08ded95324314597f/diff:/var/lib/docker/overlay2/6b3eae5e3b2adba7114d823d2321b272c59f5ae58408ce1e88c97eb98614873e/diff:/var/lib/docker/overlay2/b466e47668a96fdb8c1a622c30a827c9c0073448ddcfbe57fb3d2be5fa8881c4/diff:/var/lib/docker/overlay2/ffef761f24efe242c032951ef1bf10134bb1a541bd66b04d3f3c934d03c14b32/diff",
                "MergedDir": "/var/lib/docker/overlay2/705a362229df9caa92a7df72427890ea99ab01f04fc0d3056e55d50f69fe0214/merged",
                "UpperDir": "/var/lib/docker/overlay2/705a362229df9caa92a7df72427890ea99ab01f04fc0d3056e55d50f69fe0214/diff",
                "WorkDir": "/var/lib/docker/overlay2/705a362229df9caa92a7df72427890ea99ab01f04fc0d3056e55d50f69fe0214/work"
            }
        },
        "Mounts": [
            {
                "Type": "bind",
                "Source": "/deploy/app/log",
                "Destination": "/home/primelog",
                "Mode": "",
                "RW": true,
                "Propagation": "rprivate"
            }
        ],
        "Config": {
            "Hostname": "9b7127d72e8c",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "5000/tcp": {},
                "80/tcp": {}
            },
            "Tty": true,
            "OpenStdin": true,
            "StdinOnce": false,
            "Env": [
                "DEMS_ENV=product",
                "PATH=/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "LANG=C.UTF-8",
                "GPG_KEY=0D96DF4D4110E5C43FBFB17F2D347EA6AA65421D",
                "PYTHON_VERSION=3.7.0",
                "PYTHON_PIP_VERSION=18.0",
                "PYTHONIOENCODING=utf-8"
            ],
            "Cmd": [
                "/usr/bin/supervisord"
            ],
            "ArgsEscaped": true,
            "Image": "primetmr",
            "Volumes": null,
            "WorkingDir": "/deploy/app",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": {
                "author": "wrui",
                "purpose": "= "
            }
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "2a9cfc3d58b56ede602075d4e39f3d7fb3597b0db4bf8ea1f0c5dccd625d8972",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {
                "5000/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "5000"
                    }
                ],
                "80/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "90"
                    }
                ]
            },
            "SandboxKey": "/var/run/docker/netns/2a9cfc3d58b5",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "",
            "Gateway": "",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "",
            "IPPrefixLen": 0,
            "IPv6Gateway": "",
            "MacAddress": "",
            "Networks": {
                "isolated_nw": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": [
                        "9b7127d72e8c"
                    ],
                    "NetworkID": "2b169058c11e359b8add8d7cd7949936039dae21f6b0a0dbf26e6ed83df8422b",
                    "EndpointID": "fe83ca9952dadc80278adba7f96095be542a565139ba24ff6f63cdf486d62775",
                    "Gateway": "172.25.0.1",
                    "IPAddress": "172.25.0.3",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:ac:19:00:03"
                }
            }
        }
    }
]

共有1个答案

龙成仁
2023-03-14

在官方网站上找到https://docs.docker.com/storage/bind-mounts/

装载的来源。对于绑定装载,这是Docker守护程序主机上的文件或目录的路径。可以指定为source或src
目标将文件或目录装入容器的路径作为其值。可以指定为目标、dst或目标。

它们在docker run命令中排序错误。

 类似资料:
  • 问题内容: 我确信这个问题已经被问过很多次了,但是我没有遇到任何问题。我在配置Zend框架的地方使用XAMPP。 XAMPP在 端口8081 上运行,因为 80 正在被某些Windows进程占用,因此我需要使用以下(或在较新版本中)以下代码配置的虚拟主机。 并使用来更新hosts文件,并尝试重新启动apache,但显示错误。 问题答案: 我看到两个错误: 固定版本: 一件事要提到: 您可以随时尝试

  • 我正在使用LinuxMint17.3,并试图在Apache2.4上创建虚拟主机。我已按照以下步骤操作,但仍然无法浏览该网站: > 修改每个主机 sudo vim/etc/apache2/sites available/site1。通用域名格式。conf 服务器名站点1。com 服务器别名www.site1。com ServerAdminadmin@site1.com DocumentRoot/va

  • 我正在为rails和ember使用docker容器。我正在将源代码从本地安装到容器。我在local上所做的所有更改都反映在容器中。 现在我想使用生成器来创建文件。文件已创建,但在我的机器上受写保护。 当我尝试执行时,我在容器内部获得了超级用户提示访问。当我处于这种模式时,我可以创建文件。这些文件在我的主机中受到写保护。 我还尝试了docker compose run——用户“$(id-u):$(i

  • 问题内容: 我在Linux机器(RHEL 5.4)上使用Java 1.4.2。 我们的应用程序使用log4j进行日志记录。我希望某些附加程序可以创建文件名中包含主机名的文件。不应对主机名进行硬编码,而应使用类似于此处的系统属性(请参见$ {log4j.minutes})。 所以问题是系统属性中是否有主机名。根据此处,没有默认的主机名属性。 这意味着我需要从命令行(-D标志)的代码中添加主机名作为系

  • 问题内容: 在阅读有关Jenkins安装的信息时,许多指南都谈到安装程序在OS X上创建了一个名为“ Jenkins”的用户。该用户似乎对某些任务很重要。但是,使用自制软件安装Jenkins 2.32不会在此处安装该用户。为什么会这样-我错过了什么吗? 背景:我想将CI for iOS与Gitlab服务器一起运行。 问题答案: 通过Homebrew安装的Jenkins有点混乱-之所以这么说,是因为

  • 我正在使用Win7和我所有的asp。net应用程序正在端口80上运行 我有WAMP安装在c:\wamp和我的php项目文件夹下c:\wamp\www\作为投影1,投影2等, 现在,我尝试使用以下步骤创建虚拟主机 1)编辑主机文件并添加如下 2)打开文件"httpd.conf"在"C:/wamp/bin/apache/Apache2.2.22/conf/"和取消注释行"包括conf/额外的/http