我对 Docker 比较陌生,我正在尝试使用 docker-compose 从我的 Dockerfile 构建单个自定义映像。
Dockerfile
FROM continuumio/anaconda3
#create a directory
WORKDIR /home/docker/qts
#copy the dependencies file
COPY ./requirements.txt .
#install necessary packages
RUN pip install --no-cache-dir -r requirements.txt
#Expose ports
EXPOSE 5000
码头工人-compose.yml
version: "3.8"
services:
pyimg:
build: .
ports:
- 5000:5000
volumes:
- $HOME/Documents/qts:/home/docker/qts
我的问题
运行docker-compose build
没有给我任何错误。当我执行docker run -it <image_name> bash
并导航到目录 /home/docker/qts 时,该目录不会镜像本地目录。
Adocker inspect
还显示未安装卷(并且我暴露的端口也没有映射到本地端口!)我在这里缺少什么?
谢谢您的意见。
[
{
"Id": "cc506e95df8788349090b310bfa6965b56dbb9e218efe4a9024eb2f502a2d2f2",
"Created": "2021-02-27T14:44:14.9474339Z",
"Path": "bash",
"Args": [],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 2712,
"ExitCode": 0,
"Error": "",
"StartedAt": "2021-02-27T14:44:15.2955648Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "sha256:332985fd4830584b0356f0bf28500f5b951f7ae1fb0e0b5d774c264e28a900e3",
"ResolvConfPath": "/var/lib/docker/containers/cc506e95df8788349090b310bfa6965b56dbb9e218efe4a9024eb2f502a2d2f2/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/cc506e95df8788349090b310bfa6965b56dbb9e218efe4a9024eb2f502a2d2f2/hostname",
"HostsPath": "/var/lib/docker/containers/cc506e95df8788349090b310bfa6965b56dbb9e218efe4a9024eb2f502a2d2f2/hosts",
"LogPath": "/var/lib/docker/containers/cc506e95df8788349090b310bfa6965b56dbb9e218efe4a9024eb2f502a2d2f2/cc506e95df8788349090b310bfa6965b56dbb9e218efe4a9024eb2f502a2d2f2-json.log",
"Name": "/determined_aryabhata",
"RestartCount": 0,
"Driver": "overlay2",
"Platform": "linux",
"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,
"CgroupnsMode": "host",
"Dns": [],
"DnsOptions": [],
"DnsSearch": [],
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "private",
"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": [],
"BlkioDeviceReadBps": null,
"BlkioDeviceWriteBps": null,
"BlkioDeviceReadIOps": null,
"BlkioDeviceWriteIOps": null,
"CpuPeriod": 0,
"CpuQuota": 0,
"CpuRealtimePeriod": 0,
"CpuRealtimeRuntime": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": [],
"DeviceCgroupRules": null,
"DeviceRequests": null,
"KernelMemory": 0,
"KernelMemoryTCP": 0,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": null,
"OomKillDisable": false,
"PidsLimit": null,
"Ulimits": null,
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0,
"MaskedPaths": [
"/proc/asound",
"/proc/acpi",
"/proc/kcore",
"/proc/keys",
"/proc/latency_stats",
"/proc/timer_list",
"/proc/timer_stats",
"/proc/sched_debug",
"/proc/scsi",
"/sys/firmware"
],
"ReadonlyPaths": [
"/proc/bus",
"/proc/fs",
"/proc/irq",
"/proc/sys",
"/proc/sysrq-trigger"
]
},
"GraphDriver": {
"Data": {
"LowerDir": "/var/lib/docker/overlay2/a802a922e08dd98e4dcebea8253d2457393aa5380ba31698087ebab7c20c7420-init/diff:/var/lib/docker/overlay2/7fd10d3a3749cfbcfb8ba4bffbe4d5ec9b70c0244f18d8bcbc10e50526fa2836/diff:/var/lib/docker/overlay2/a951e71a24b2c5635f34fbac57fe02e902ffa55928854bd63918c3a0eac8bd6a/diff:/var/lib/docker/overlay2/67defaf9804e20dbe3bb9b06a68301b527cebf5ad15103d129b564b4678f65eb/diff:/var/lib/docker/overlay2/7e88aebe633878bdd3fe36eb842259d1e898f64fd6937a47ac7b32cb77958fe0/diff:/var/lib/docker/overlay2/61c831913d4448f0efa8b78852181b45c993aa6d5d6b1d7b01e85f936121ab4d/diff:/var/lib/docker/overlay2/dc34279b6529ec9d0123de5a46520de90775fe9ad0d87f8e8a572085df7bf3d3/diff",
"MergedDir": "/var/lib/docker/overlay2/a802a922e08dd98e4dcebea8253d2457393aa5380ba31698087ebab7c20c7420/merged",
"UpperDir": "/var/lib/docker/overlay2/a802a922e08dd98e4dcebea8253d2457393aa5380ba31698087ebab7c20c7420/diff",
"WorkDir": "/var/lib/docker/overlay2/a802a922e08dd98e4dcebea8253d2457393aa5380ba31698087ebab7c20c7420/work"
},
"Name": "overlay2"
},
"Mounts": [],
"Config": {
"Hostname": "cc506e95df87",
"Domainname": "",
"User": "",
"AttachStdin": true,
"AttachStdout": true,
"AttachStderr": true,
"ExposedPorts": {
"5000/tcp": {}
},
"Tty": true,
"OpenStdin": true,
"StdinOnce": true,
"Env": [
"PATH=/opt/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",