Docker Community Forums

Share and learn in the Docker community.

Volume=null, what am I doing wrong?

Hi there,
First of all, Happy New Year!

I’m trying to build a nodejs image but the volume mounting does not work. It works for others containers built (nginx, mongo, etc…) but for unknown reason when I inspect the image created as a result of the docker-compose build process, the volume is null:

nacho@Ignacios-MacBook-Pro nodejs % docker inspect 59c32258a5c0
[
{
“Id”: “59c32258a5c0606c156c110964c36d83bece6588466797c1e660eba962ff4fb0”,
“Created”: “2021-01-01T20:05:53.498433207Z”,
“Path”: “docker-entrypoint.sh”,
“Args”: [
“/bin/sh”
],
“State”: {
“Status”: “running”,
“Running”: true,
“Paused”: false,
“Restarting”: false,
“OOMKilled”: false,
“Dead”: false,
“Pid”: 2725,
“ExitCode”: 0,
“Error”: “”,
“StartedAt”: “2021-01-01T20:05:53.812019299Z”,
“FinishedAt”: “0001-01-01T00:00:00Z”
},
“Image”: “sha256:3e3af21a99b6fd41a8bdbd3fa315c91f1a329692810db667681b2ff268800d9e”,
“ResolvConfPath”: “/var/lib/docker/containers/59c32258a5c0606c156c110964c36d83bece6588466797c1e660eba962ff4fb0/resolv.conf”,
“HostnamePath”: “/var/lib/docker/containers/59c32258a5c0606c156c110964c36d83bece6588466797c1e660eba962ff4fb0/hostname”,
“HostsPath”: “/var/lib/docker/containers/59c32258a5c0606c156c110964c36d83bece6588466797c1e660eba962ff4fb0/hosts”,
“LogPath”: “/var/lib/docker/containers/59c32258a5c0606c156c110964c36d83bece6588466797c1e660eba962ff4fb0/59c32258a5c0606c156c110964c36d83bece6588466797c1e660eba962ff4fb0-json.log”,
“Name”: “/gracious_hugle”,
“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,
“Capabilities”: null,
“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/43ab2fd9c27aee7fff008174d5b78ea70090ff06ed698d1cfcebd7a031710440-init/diff:/var/lib/docker/overlay2/6664598e17871ef153b9c1478769479b4d4c5b760812c772dffc4f8b7811a6bf/diff:/var/lib/docker/overlay2/bcc5d132d5bacff1939d50eb4dd8b632e8d5c13f6c2051bb00313e13fcf9ce3e/diff:/var/lib/docker/overlay2/4cf2cfbad32d6fc4787bf9c9cc50fb36abf1d887d9da4afb031de04aab23ee63/diff:/var/lib/docker/overlay2/1c939ab930f5d3b9b996113295a83133420edb3dadfc5bc7c8da864b4b172c8f/diff:/var/lib/docker/overlay2/d7cfb0b4eb032a98ef88cb4607d381ebc467c4e7bc0cd75ecc5d87d56d4afba5/diff:/var/lib/docker/overlay2/e9a168719fb8b81e71d3c339986c990c704722a2e31bc1a19f6b5f30269db6e8/diff”,
“MergedDir”: “/var/lib/docker/overlay2/43ab2fd9c27aee7fff008174d5b78ea70090ff06ed698d1cfcebd7a031710440/merged”,
“UpperDir”: “/var/lib/docker/overlay2/43ab2fd9c27aee7fff008174d5b78ea70090ff06ed698d1cfcebd7a031710440/diff”,
“WorkDir”: “/var/lib/docker/overlay2/43ab2fd9c27aee7fff008174d5b78ea70090ff06ed698d1cfcebd7a031710440/work”
},
“Name”: “overlay2”
},
“Mounts”: ,
“Config”: {
“Hostname”: “59c32258a5c0”,
“Domainname”: “”,
“User”: “”,
“AttachStdin”: true,
“AttachStdout”: true,
“AttachStderr”: true,
“Tty”: true,
“OpenStdin”: true,
“StdinOnce”: true,
“Env”: [
“PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin”,
“NODE_VERSION=15.5.0”,
“YARN_VERSION=1.22.5”
],
“Cmd”: [
“/bin/sh”
],
“Image”: “nodejs_nodejs-svc”,
"Volumes": null,
“WorkingDir”: “/var/app/backend”,
“Entrypoint”: [
“docker-entrypoint.sh”
],
“OnBuild”: null,
“Labels”: {}
},
“NetworkSettings”: {
“Bridge”: “”,
“SandboxID”: “5cf5ff3af9bdf939f0124f180d68cc17d5b94f41b20aed82121bb05649711dfc”,
“HairpinMode”: false,
“LinkLocalIPv6Address”: “”,
“LinkLocalIPv6PrefixLen”: 0,
“Ports”: {},
“SandboxKey”: “/var/run/docker/netns/5cf5ff3af9bd”,
“SecondaryIPAddresses”: null,
“SecondaryIPv6Addresses”: null,
“EndpointID”: “023c714247f7752eb87178058275723a959e0df50d3799812f0846332409b310”,
“Gateway”: “172.17.0.1”,
“GlobalIPv6Address”: “”,
“GlobalIPv6PrefixLen”: 0,
“IPAddress”: “172.17.0.2”,
“IPPrefixLen”: 16,
“IPv6Gateway”: “”,
“MacAddress”: “02:42:ac:11:00:02”,
“Networks”: {
“bridge”: {
“IPAMConfig”: null,
“Links”: null,
“Aliases”: null,
“NetworkID”: “d13cb30e03fc2d51a47c723009201aa63b89f9fdd1ce50cc1f4b1c2ca9c4794d”,
“EndpointID”: “023c714247f7752eb87178058275723a959e0df50d3799812f0846332409b310”,
“Gateway”: “172.17.0.1”,
“IPAddress”: “172.17.0.2”,
“IPPrefixLen”: 16,
“IPv6Gateway”: “”,
“GlobalIPv6Address”: “”,
“GlobalIPv6PrefixLen”: 0,
“MacAddress”: “02:42:ac:11:00:02”,
“DriverOpts”: null
}
}
}
}
]

here the Dockerfile:

FROM node:alpine
RUN mkdir -p /var/app/backend
WORKDIR /var/app/backend
COPY . .

and the docker-compose.yaml:
version: “3.8”
services:
nodejs-svc:
build:
context: .
dockerfile: Dockerfile
args:
MY_ARG: “Soy un argumento desde docker-compose-nodejs”

container_name: my-nodejs

# <localhost>:<container>
#ports:
#  - 27017:27017

# <localhost>:<container>
volumes: 
  #- /Users/nacho/docker-data/nodejs:/var/app/backend  
  - type: volume
    source: docker-data
    target: /var/app/backend

#restart: configuración para reiniciar el servicio. Tiene cuatro valores:
    # "no" (valor por defecto)
    # always
    # on-failure
    # unless-stopped
restart: on-failure

# variables de entorno que se crean dentro del contenedor, no disponibles en la máquina host.
#environment: 
  #MY_ENV_VAR1: "este es un mensaje desde docker-compose"
  #MY_ENV_VAR2: "otra variable"

volumes:
docker-data:

networks:

the docker-compose build process ends ok and the image is created. From there, I run the new image through docker run and I see the target folder with the data copied from my host to the container but after that, if I add a new file or modify one existing nothing happens, obviously, as the docker inspect outcome shows, there is no volume created, but… why???

Thanks in advance for you support,