Hi everyone,
I have mounted a folder in a path in Linux to a partition.
Then, I created a container from a PostgreSQL image and assigned its volume to the mounted folder.
Now, I want to increase the size of that partition.
To do this, I first stop the container, then use fdisk to increase the partition, followed by Linux commands to expand it. Finally, I start the container again.
After completing the above steps, the mounted folder correctly shows the increased space.
However, when I add a file to the volume’s path within the container, it consumes space on the root partition (/) of the Linux host instead of being stored in the volume.
What could be the issue? Please guide me.
Please share how you create the container:
- If created by
docker run
, the exactdocker run
command. - If created by
docker compose up
, the content of the compose file.
There is a distinction between named volumes (mounting a docker manged volume handle into a container path) and binds (bind mounting a host path into a container path). Both use the volume argument to be mapped into the container.
If you created a named volume (docker volume create/inside a compose file), we need to see the configuration of the named volume as well.
Thank you for reply,
Here is my yaml file, I run it with the stack component of Portainer
before running stack, I run this command to create volume: docker create volume core_pg_db
version: ‘2.1’
services:
core_postgresql:
container_name: core_pg_db
image: ${CORE_POSTGRESQL_DB_IMAGE_NAME}
restart: always
environment:
POSTGRES_USER: ${CORE_POSTGRESQL_DB_USERNAME}
POSTGRES_PASSWORD: ${CORE_POSTGRESQL_DB_PASSWORD}
POSTGRES_DB: ${CORE_POSTGRESQL_DB_NAME}
POSTGRES_PORT: ${CORE_POSTGRESQL_DB_LOCAL_PORT}
networks:
internal_operation:
volumes:
- core_pg_db:/var/lib/postgresql/data
healthcheck:
test: [ “CMD”, “pg_isready”, “-q”, “-d”, “${CORE_POSTGRESQL_DB_NAME}”, “-U”, “${CORE_POSTGRESQL_DB_USERNAME}” ]
timeout: 45s
interval: 10s
retries: 10
==[VOLUMES SECTION]===
volumes:
core_pg_db:
external: true
Please next time format your post according https://forums.docker.com/t/how-to-format-your-forum-posts/. The way the compose file is posted, it is hard to read and does not allow seeing if indentation is correct.
Please add this as well. If a volume is declared as external in a compose file, it specifically means that it was created outside the compose file, and we can not see how it’s configured.
Here is my docker compose file:
Here is my yaml file, I run it with the stack component of Portainer
before running stack, I run this command to create volume: docker create volume core_pg_db
version: '2.1'
services:
core_postgresql:
container_name: core_pg_db
image: ${CORE_POSTGRESQL_DB_IMAGE_NAME}
restart: always
environment:
POSTGRES_USER: ${CORE_POSTGRESQL_DB_USERNAME}
POSTGRES_PASSWORD: ${CORE_POSTGRESQL_DB_PASSWORD}
POSTGRES_DB: ${CORE_POSTGRESQL_DB_NAME}
POSTGRES_PORT: ${CORE_POSTGRESQL_DB_LOCAL_PORT}
networks:
internal_operation:
volumes:
- core_pg_db:/var/lib/postgresql/data
healthcheck:
test: [ "CMD", "pg_isready", "-q", "-d", "${CORE_POSTGRESQL_DB_NAME}", "-U", "${CORE_POSTGRESQL_DB_USERNAME}" ]
timeout: 45s
interval: 10s
retries: 10
# ==[VOLUMES SECTION]===
volumes:
core_pg_db:
external: true
and as I mentioned before, I use this below command to create the volume:
docker create volume core_pg_db
Here is my docker compose file:
version: '2.1'
services:
core_postgresql:
container_name: core_pg_db
image: ${CORE_POSTGRESQL_DB_IMAGE_NAME}
restart: always
environment:
POSTGRES_USER: ${CORE_POSTGRESQL_DB_USERNAME}
POSTGRES_PASSWORD: ${CORE_POSTGRESQL_DB_PASSWORD}
POSTGRES_DB: ${CORE_POSTGRESQL_DB_NAME}
POSTGRES_PORT: ${CORE_POSTGRESQL_DB_LOCAL_PORT}
networks:
internal_operation:
volumes:
- core_pg_db:/var/lib/postgresql/data
healthcheck:
test: [ "CMD", "pg_isready", "-q", "-d", "${CORE_POSTGRESQL_DB_NAME}", "-U", "${CORE_POSTGRESQL_DB_USERNAME}" ]
timeout: 45s
interval: 10s
retries: 10
# ==[VOLUMES SECTION]===
volumes:
core_pg_db:
external: true
and as I mentioned before, I use the below command to create the volume before running stack via portainer:
docker create volume core_pg_db
This creates a named volume in the docker root dir. You need to increate the partition size of the filesystem that is mounted in the docker root dir or in one of it’s parent folders.
docker info --format '{{.DockerRootDir}}'
Your volume is located here:
echo "$(docker info --format '{{.DockerRootDir}}')/volumes/core_pg_db"
It is just part of the filesystem that is managed by docker, it is not a block device with fixed size. You need to fix it on the underying filesystem.
But 3 things
- why another container with the same configuration works fine? I mean when I add files to volume in a docker container, the exact mount point in the host got increased?
- why do I have the exact files as same as the container in my mounted host for the first container?
check the below:
but after I copy file in the above folder in container, the size of / increased
- what is the right solution that I have to do?
I am not sure what to say about the questions.
Also, I never look at text posted as screenshot. If you want me to look at it, please post it as Preformated Text.
Please share the output of:
docker inspect volume core_pg_db
If something works for a volume and doesn’t work for another, please share the inspect output for both of them.
I think it was more understandable with screenshots,
for my previous screenshots:
on host:
root@lsr-deployment:~# df -h | grep volume
/dev/sdd1 989M 28K 922M 1% /var/volumes/traffic
/dev/sdc1 989M 7.6M 914M 1% /var/volumes/syslog
/dev/sdb1 989M 70M 852M 8% /var/volumes/postgres
root@lsr-deployment:~# ls -lh /var/volumes/postgres/data/
total 120K
drwx------ 6 systemd-coredump systemd-coredump 4.0K Jun 20 15:14 base
drwx------ 2 systemd-coredump systemd-coredump 4.0K Jun 28 10:28 global
drwx------ 2 systemd-coredump systemd-coredump 4.0K Jun 20 15:14 pg_commit_ts
drwx------ 2 systemd-coredump systemd-coredump 4.0K Jun 20 15:14 pg_dynshmem
-rw------- 1 systemd-coredump systemd-coredump 4.5K Jun 20 15:14 pg_hba.conf
-rw------- 1 systemd-coredump systemd-coredump 1.6K Jun 20 15:14 pg_ident.conf
drwx------ 4 systemd-coredump systemd-coredump 4.0K Jun 28 10:32 pg_logical
drwx------ 4 systemd-coredump systemd-coredump 4.0K Jun 20 15:14 pg_multixact
drwx------ 2 systemd-coredump systemd-coredump 4.0K Jun 28 10:27 pg_notify
drwx------ 2 systemd-coredump systemd-coredump 4.0K Jun 20 15:14 pg_replslot
drwx------ 2 systemd-coredump systemd-coredump 4.0K Jun 20 15:14 pg_serial
drwx------ 2 systemd-coredump systemd-coredump 4.0K Jun 20 15:14 pg_snapshots
drwx------ 2 systemd-coredump systemd-coredump 4.0K Jun 28 10:27 pg_stat
drwx------ 2 systemd-coredump systemd-coredump 4.0K Jun 28 10:32 pg_stat_tmp
drwx------ 2 systemd-coredump systemd-coredump 4.0K Jun 20 15:14 pg_subtrans
drwx------ 2 systemd-coredump systemd-coredump 4.0K Jun 20 15:14 pg_tblspc
drwx------ 2 systemd-coredump systemd-coredump 4.0K Jun 20 15:14 pg_twophase
-rw------- 1 systemd-coredump systemd-coredump 3 Jun 20 15:14 PG_VERSION
drwx------ 3 systemd-coredump systemd-coredump 4.0K Jun 21 03:35 pg_wal
drwx------ 2 systemd-coredump systemd-coredump 4.0K Jun 20 15:14 pg_xact
-rw------- 1 systemd-coredump systemd-coredump 88 Jun 20 15:14 postgresql.auto.conf
-rw------- 1 systemd-coredump systemd-coredump 24K Jun 20 15:14 postgresql.conf
-rw------- 1 systemd-coredump systemd-coredump 36 Jun 28 10:27 postmaster.opts
-rw------- 1 systemd-coredump systemd-coredump 94 Jun 28 10:27 postmaster.pid
on container:
root@2e0f18a31dff:/# ls -lh /var/lib/postgresql/data
total 120K
drwx------ 6 postgres postgres 4.0K Jun 20 11:44 base
drwx------ 2 postgres postgres 4.0K Jun 28 07:06 global
drwx------ 2 postgres postgres 4.0K Jun 20 11:44 pg_commit_ts
drwx------ 2 postgres postgres 4.0K Jun 20 11:44 pg_dynshmem
-rw------- 1 postgres postgres 4.5K Jun 20 11:44 pg_hba.conf
-rw------- 1 postgres postgres 1.6K Jun 20 11:44 pg_ident.conf
drwx------ 4 postgres postgres 4.0K Jun 28 07:04 pg_logical
drwx------ 4 postgres postgres 4.0K Jun 20 11:44 pg_multixact
drwx------ 2 postgres postgres 4.0K Jun 28 07:05 pg_notify
drwx------ 2 postgres postgres 4.0K Jun 20 11:44 pg_replslot
drwx------ 2 postgres postgres 4.0K Jun 20 11:44 pg_serial
drwx------ 2 postgres postgres 4.0K Jun 20 11:44 pg_snapshots
drwx------ 2 postgres postgres 4.0K Jun 28 07:05 pg_stat
drwx------ 2 postgres postgres 4.0K Jun 28 07:06 pg_stat_tmp
drwx------ 2 postgres postgres 4.0K Jun 20 11:44 pg_subtrans
drwx------ 2 postgres postgres 4.0K Jun 20 11:44 pg_tblspc
drwx------ 2 postgres postgres 4.0K Jun 20 11:44 pg_twophase
-rw------- 1 postgres postgres 3 Jun 20 11:44 PG_VERSION
drwx------ 3 postgres postgres 4.0K Jun 21 00:05 pg_wal
drwx------ 2 postgres postgres 4.0K Jun 20 11:44 pg_xact
-rw------- 1 postgres postgres 88 Jun 20 11:44 postgresql.auto.conf
-rw------- 1 postgres postgres 24K Jun 20 11:44 postgresql.conf
-rw------- 1 postgres postgres 36 Jun 28 07:05 postmaster.opts
-rw------- 1 postgres postgres 94 Jun 28 07:05 postmaster.pid
and for your question:
docker inspect volume core_pg_db
[
{
"Id": "2e0f18a31dff4636768835f425ef2202cee8e6ed27de5d7b570bbdef4d6b4ad7",
"Created": "2023-06-28T07:04:58.757776085Z",
"Path": "docker-entrypoint.sh",
"Args": [
"postgres"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 2472496,
"ExitCode": 0,
"Error": "",
"StartedAt": "2023-06-28T07:05:11.389287965Z",
"FinishedAt": "0001-01-01T00:00:00Z",
"Health": {
"Status": "healthy",
"FailingStreak": 0,
"Log": [
{
"Start": "2023-06-28T10:36:35.376742406+03:30",
"End": "2023-06-28T10:36:35.605032261+03:30",
"ExitCode": 0,
"Output": ""
},
{
"Start": "2023-06-28T10:36:45.851472142+03:30",
"End": "2023-06-28T10:36:46.085027747+03:30",
"ExitCode": 0,
"Output": ""
},
{
"Start": "2023-06-28T10:36:56.246704983+03:30",
"End": "2023-06-28T10:36:56.5088495+03:30",
"ExitCode": 0,
"Output": ""
},
{
"Start": "2023-06-28T10:37:06.6142405+03:30",
"End": "2023-06-28T10:37:06.805343095+03:30",
"ExitCode": 0,
"Output": ""
},
{
"Start": "2023-06-28T10:37:16.911246152+03:30",
"End": "2023-06-28T10:37:17.214999301+03:30",
"ExitCode": 0,
"Output": ""
}
]
}
},
"Image": "sha256:73d7afcdd35977a90a6e205b5e23a0c79ca60a62161d458350af4609f5bc1e2c",
"ResolvConfPath": "/var/lib/docker/containers/2e0f18a31dff4636768835f425ef2202cee8e6ed27de5d7b570bbdef4d6b4ad7/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/2e0f18a31dff4636768835f425ef2202cee8e6ed27de5d7b570bbdef4d6b4ad7/hostname",
"HostsPath": "/var/lib/docker/containers/2e0f18a31dff4636768835f425ef2202cee8e6ed27de5d7b570bbdef4d6b4ad7/hosts",
"LogPath": "/var/lib/docker/containers/2e0f18a31dff4636768835f425ef2202cee8e6ed27de5d7b570bbdef4d6b4ad7/2e0f18a31dff4636768835f425ef2202cee8e6ed27de5d7b570bbdef4d6b4ad7-json.log",
"Name": "/ibsng_core_pg_db",
"RestartCount": 0,
"Driver": "overlay2",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "docker-default",
"ExecIDs": [
"2d263bdcccac7430c5f4f259b6657bf2a6019360f9752138c6d85bee006511fc"
],
"HostConfig": {
"Binds": null,
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "pp_internal_operation",
"PortBindings": {},
"RestartPolicy": {
"Name": "always",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": null,
"ConsoleSize": [
0,
0
],
"CapAdd": null,
"CapDrop": null,
"CgroupnsMode": "private",
"Dns": null,
"DnsOptions": null,
"DnsSearch": null,
"ExtraHosts": [],
"GroupAdd": null,
"IpcMode": "private",
"Cgroup": "",
"Links": null,
"OomScoreAdj": 0,
"PidMode": "",
"Privileged": false,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"SecurityOpt": null,
"UTSMode": "",
"UsernsMode": "",
"ShmSize": 67108864,
"Runtime": "runc",
"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": null,
"DeviceCgroupRules": null,
"DeviceRequests": null,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": null,
"OomKillDisable": null,
"PidsLimit": null,
"Ulimits": null,
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0,
"Mounts": [
{
"Type": "volume",
"Source": "ibsng_core_pg_db",
"Target": "/var/lib/postgresql/data",
"VolumeOptions": {}
}
],
"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/9333aaf12e268817f27deb323807ce62d728a9bb08a35e2f1877ad1a56552afe-init/diff:/var/lib/docker/overlay2/8969d9614372e1d100fc7ef8efc569c38c6e41e219d1a4a3f38043cd83616afc/diff:/var/lib/docker/overlay2/4199ae9abad25725262ad1481a0f5f8c81fdbc3ef230a5f31a3b612a1c3b4253/diff:/var/lib/docker/overlay2/5c2838928ec329683c1b23d3745e6395ae589d3b61243cc13c1cccec21d067e2/diff:/var/lib/docker/overlay2/4a4019c80777c388ca9701b4e6915317394f470f6829cd3172dff33fcc942641/diff:/var/lib/docker/overlay2/86bdb7469d4ce120bfa29394a28fe9a7728f072c05b9291e523f588aaa1682ee/diff:/var/lib/docker/overlay2/9e471d3e443af8ebf0ca1af4e3430a709b189b4b3b129ddb131233d825632949/diff:/var/lib/docker/overlay2/b8068ca54fb9ba10293766b93cabb113ab7a56d33ffdb3686c775ac9f527c84b/diff:/var/lib/docker/overlay2/88450260e6f174d3cee7906ac3db6ef30fa7246fe36519e4d694e44c132863dc/diff:/var/lib/docker/overlay2/098ebed45381bd4c42a94eb2a2f59e8bf8b02bf6589eb35ef3eaf5160b74b2f2/diff:/var/lib/docker/overlay2/30ca681e26354f26aaf26d20debb4ca8dcb03e88ddced43c886e038f73182c18/diff:/var/lib/docker/overlay2/f5b447aa250b152ebd5444cf7d17ee72d4064067e5e8501c668fe14788b3e3e0/diff:/var/lib/docker/overlay2/b9e2ab0c11897f6d02a7e3e8d84f72fb012e9377febd701f140edbe1b4be2a97/diff:/var/lib/docker/overlay2/39c177c8025f77a186997c6c0103c385d1dfd826c68b54d431216c842a210f9b/diff:/var/lib/docker/overlay2/15e31d31b0b045176c604e87f9c0febca8b34b639e27c9cfe9ea5ead1ab1bdd8/diff:/var/lib/docker/overlay2/1484fde047ccc8e37ea31bcad97be969fe9d47a4751a33b29d5da8c41bee26d7/diff:/var/lib/docker/overlay2/136eca2cccc8afe8af7fefa8bb80faf75c9aa467061afc361b2f019b1cd95095/diff:/var/lib/docker/overlay2/3cbe8aca0152355718ab3816a072eea1160df92b53f18acd60c8a0ffef3ebb62/diff",
"MergedDir": "/var/lib/docker/overlay2/9333aaf12e268817f27deb323807ce62d728a9bb08a35e2f1877ad1a56552afe/merged",
"UpperDir": "/var/lib/docker/overlay2/9333aaf12e268817f27deb323807ce62d728a9bb08a35e2f1877ad1a56552afe/diff",
"WorkDir": "/var/lib/docker/overlay2/9333aaf12e268817f27deb323807ce62d728a9bb08a35e2f1877ad1a56552afe/work"
},
"Name": "overlay2"
},
"Mounts": [
{
"Type": "volume",
"Name": "ibsng_core_pg_db",
"Source": "/var/lib/docker/volumes/ibsng_core_pg_db/_data",
"Destination": "/var/lib/postgresql/data",
"Driver": "local",
"Mode": "z",
"RW": true,
"Propagation": ""
}
],
"Config": {
"Hostname": "2e0f18a31dff",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": true,
"AttachStderr": true,
"ExposedPorts": {
"5432/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"POSTGRES_USER=ibs",
"POSTGRES_PASSWORD=KJDHG4578HKDGHI348hfgjnmcbv",
"POSTGRES_DB=IBSng",
"POSTGRES_PORT=5432",
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/postgresql/11/bin",
"GOSU_VERSION=1.14",
"LANG=en_US.utf8",
"PG_MAJOR=11",
"PG_VERSION=11.18-1.pgdg110+1",
"PGDATA=/var/lib/postgresql/data"
],
"Cmd": [
"postgres"
],
"Healthcheck": {
"Test": [
"CMD",
"pg_isready",
"-q",
"-d",
"IBSng",
"-U",
"ibs"
],
"Interval": 10000000000,
"Timeout": 45000000000,
"Retries": 10
},
"Image": "registry.parspooyesh.net/ibsng-database",
"Volumes": {
"/var/lib/postgresql/data": {}
},
"WorkingDir": "",
"Entrypoint": [
"docker-entrypoint.sh"
],
"OnBuild": null,
"Labels": {
"com.docker.compose.config-hash": "83c8cc29c1772c43388558e48e11141bbca38a96b83225f8db10b167e5a6a706",
"com.docker.compose.container-number": "1",
"com.docker.compose.depends_on": "",
"com.docker.compose.image": "sha256:73d7afcdd35977a90a6e205b5e23a0c79ca60a62161d458350af4609f5bc1e2c",
"com.docker.compose.oneoff": "False",
"com.docker.compose.project": "parspooyesh",
"com.docker.compose.project.config_files": "/data/compose/2/docker-compose.yml",
"com.docker.compose.project.environment_file": "/data/compose/2/stack.env",
"com.docker.compose.project.working_dir": "/data/compose/2",
"com.docker.compose.service": "ibsng_core_postgresql",
"com.docker.compose.version": "2.17.2"
},
"StopSignal": "SIGINT"
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "4cf017d6524f81a35b159b1748bd46673cb5ab120e71b1e59c527d4d7825dfc9",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"5432/tcp": null
},
"SandboxKey": "/var/run/docker/netns/4cf017d6524f",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "",
"Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"MacAddress": "",
"Networks": {
"pp_internal_operation": {
"IPAMConfig": null,
"Links": null,
"Aliases": [
"ibsng_core_pg_db",
"ibsng_core_postgresql",
"2e0f18a31dff"
],
"NetworkID": "f412efd77899fb18895697f71feba9838532e34e9c3860c24416af091875067d",
"EndpointID": "bd5bfb54bc36532484fa40c8cf9db6d5e85894cf188d1c9d305180e99e8a7a23",
"Gateway": "172.20.20.1",
"IPAddress": "172.20.20.4",
"IPPrefixLen": 24,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:14:14:04",
"DriverOpts": null
}
}
}
}
]
Error: No such object: volume
I should mention that I change it to “ibsng_core_pg_db”
and inspect for working container:
[
{
"Id": "2e0f18a31dff4636768835f425ef2202cee8e6ed27de5d7b570bbdef4d6b4ad7",
"Created": "2023-06-28T07:04:58.757776085Z",
"Path": "docker-entrypoint.sh",
"Args": [
"postgres"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 2472496,
"ExitCode": 0,
"Error": "",
"StartedAt": "2023-06-28T07:05:11.389287965Z",
"FinishedAt": "0001-01-01T00:00:00Z",
"Health": {
"Status": "healthy",
"FailingStreak": 0,
"Log": [
{
"Start": "2023-06-28T11:15:37.794025869+03:30",
"End": "2023-06-28T11:15:38.051327272+03:30",
"ExitCode": 0,
"Output": ""
},
{
"Start": "2023-06-28T11:15:48.139425278+03:30",
"End": "2023-06-28T11:15:48.332523458+03:30",
"ExitCode": 0,
"Output": ""
},
{
"Start": "2023-06-28T11:15:58.435865742+03:30",
"End": "2023-06-28T11:15:58.641358189+03:30",
"ExitCode": 0,
"Output": ""
},
{
"Start": "2023-06-28T11:16:08.705186951+03:30",
"End": "2023-06-28T11:16:08.967493708+03:30",
"ExitCode": 0,
"Output": ""
},
{
"Start": "2023-06-28T11:16:19.0417747+03:30",
"End": "2023-06-28T11:16:19.259262821+03:30",
"ExitCode": 0,
"Output": ""
}
]
}
},
"Image": "sha256:73d7afcdd35977a90a6e205b5e23a0c79ca60a62161d458350af4609f5bc1e2c",
"ResolvConfPath": "/var/lib/docker/containers/2e0f18a31dff4636768835f425ef2202cee8e6ed27de5d7b570bbdef4d6b4ad7/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/2e0f18a31dff4636768835f425ef2202cee8e6ed27de5d7b570bbdef4d6b4ad7/hostname",
"HostsPath": "/var/lib/docker/containers/2e0f18a31dff4636768835f425ef2202cee8e6ed27de5d7b570bbdef4d6b4ad7/hosts",
"LogPath": "/var/lib/docker/containers/2e0f18a31dff4636768835f425ef2202cee8e6ed27de5d7b570bbdef4d6b4ad7/2e0f18a31dff4636768835f425ef2202cee8e6ed27de5d7b570bbdef4d6b4ad7-json.log",
"Name": "/ibsng_core_pg_db",
"RestartCount": 0,
"Driver": "overlay2",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "docker-default",
"ExecIDs": null,
"HostConfig": {
"Binds": null,
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "pp_internal_operation",
"PortBindings": {},
"RestartPolicy": {
"Name": "always",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": null,
"ConsoleSize": [
0,
0
],
"CapAdd": null,
"CapDrop": null,
"CgroupnsMode": "private",
"Dns": null,
"DnsOptions": null,
"DnsSearch": null,
"ExtraHosts": [],
"GroupAdd": null,
"IpcMode": "private",
"Cgroup": "",
"Links": null,
"OomScoreAdj": 0,
"PidMode": "",
"Privileged": false,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"SecurityOpt": null,
"UTSMode": "",
"UsernsMode": "",
"ShmSize": 67108864,
"Runtime": "runc",
"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": null,
"DeviceCgroupRules": null,
"DeviceRequests": null,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": null,
"OomKillDisable": null,
"PidsLimit": null,
"Ulimits": null,
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0,
"Mounts": [
{
"Type": "volume",
"Source": "ibsng_core_pg_db",
"Target": "/var/lib/postgresql/data",
"VolumeOptions": {}
}
],
"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/9333aaf12e268817f27deb323807ce62d728a9bb08a35e2f1877ad1a56552afe-init/diff:/var/lib/docker/overlay2/8969d9614372e1d100fc7ef8efc569c38c6e41e219d1a4a3f38043cd83616afc/diff:/var/lib/docker/overlay2/4199ae9abad25725262ad1481a0f5f8c81fdbc3ef230a5f31a3b612a1c3b4253/diff:/var/lib/docker/overlay2/5c2838928ec329683c1b23d3745e6395ae589d3b61243cc13c1cccec21d067e2/diff:/var/lib/docker/overlay2/4a4019c80777c388ca9701b4e6915317394f470f6829cd3172dff33fcc942641/diff:/var/lib/docker/overlay2/86bdb7469d4ce120bfa29394a28fe9a7728f072c05b9291e523f588aaa1682ee/diff:/var/lib/docker/overlay2/9e471d3e443af8ebf0ca1af4e3430a709b189b4b3b129ddb131233d825632949/diff:/var/lib/docker/overlay2/b8068ca54fb9ba10293766b93cabb113ab7a56d33ffdb3686c775ac9f527c84b/diff:/var/lib/docker/overlay2/88450260e6f174d3cee7906ac3db6ef30fa7246fe36519e4d694e44c132863dc/diff:/var/lib/docker/overlay2/098ebed45381bd4c42a94eb2a2f59e8bf8b02bf6589eb35ef3eaf5160b74b2f2/diff:/var/lib/docker/overlay2/30ca681e26354f26aaf26d20debb4ca8dcb03e88ddced43c886e038f73182c18/diff:/var/lib/docker/overlay2/f5b447aa250b152ebd5444cf7d17ee72d4064067e5e8501c668fe14788b3e3e0/diff:/var/lib/docker/overlay2/b9e2ab0c11897f6d02a7e3e8d84f72fb012e9377febd701f140edbe1b4be2a97/diff:/var/lib/docker/overlay2/39c177c8025f77a186997c6c0103c385d1dfd826c68b54d431216c842a210f9b/diff:/var/lib/docker/overlay2/15e31d31b0b045176c604e87f9c0febca8b34b639e27c9cfe9ea5ead1ab1bdd8/diff:/var/lib/docker/overlay2/1484fde047ccc8e37ea31bcad97be969fe9d47a4751a33b29d5da8c41bee26d7/diff:/var/lib/docker/overlay2/136eca2cccc8afe8af7fefa8bb80faf75c9aa467061afc361b2f019b1cd95095/diff:/var/lib/docker/overlay2/3cbe8aca0152355718ab3816a072eea1160df92b53f18acd60c8a0ffef3ebb62/diff",
"MergedDir": "/var/lib/docker/overlay2/9333aaf12e268817f27deb323807ce62d728a9bb08a35e2f1877ad1a56552afe/merged",
"UpperDir": "/var/lib/docker/overlay2/9333aaf12e268817f27deb323807ce62d728a9bb08a35e2f1877ad1a56552afe/diff",
"WorkDir": "/var/lib/docker/overlay2/9333aaf12e268817f27deb323807ce62d728a9bb08a35e2f1877ad1a56552afe/work"
},
"Name": "overlay2"
},
"Mounts": [
{
"Type": "volume",
"Name": "ibsng_core_pg_db",
"Source": "/var/lib/docker/volumes/ibsng_core_pg_db/_data",
"Destination": "/var/lib/postgresql/data",
"Driver": "local",
"Mode": "z",
"RW": true,
"Propagation": ""
}
],
"Config": {
"Hostname": "2e0f18a31dff",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": true,
"AttachStderr": true,
"ExposedPorts": {
"5432/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"POSTGRES_USER=ibs",
"POSTGRES_PASSWORD=KJDHG4578HKDGHI348hfgjnmcbv",
"POSTGRES_DB=IBSng",
"POSTGRES_PORT=5432",
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/postgresql/11/bin",
"GOSU_VERSION=1.14",
"LANG=en_US.utf8",
"PG_MAJOR=11",
"PG_VERSION=11.18-1.pgdg110+1",
"PGDATA=/var/lib/postgresql/data"
],
"Cmd": [
"postgres"
],
"Healthcheck": {
"Test": [
"CMD",
"pg_isready",
"-q",
"-d",
"IBSng",
"-U",
"ibs"
],
"Interval": 10000000000,
"Timeout": 45000000000,
"Retries": 10
},
"Image": "registry.parspooyesh.net/ibsng-database",
"Volumes": {
"/var/lib/postgresql/data": {}
},
"WorkingDir": "",
"Entrypoint": [
"docker-entrypoint.sh"
],
"OnBuild": null,
"Labels": {
"com.docker.compose.config-hash": "83c8cc29c1772c43388558e48e11141bbca38a96b83225f8db10b167e5a6a706",
"com.docker.compose.container-number": "1",
"com.docker.compose.depends_on": "",
"com.docker.compose.image": "sha256:73d7afcdd35977a90a6e205b5e23a0c79ca60a62161d458350af4609f5bc1e2c",
"com.docker.compose.oneoff": "False",
"com.docker.compose.project": "parspooyesh",
"com.docker.compose.project.config_files": "/data/compose/2/docker-compose.yml",
"com.docker.compose.project.environment_file": "/data/compose/2/stack.env",
"com.docker.compose.project.working_dir": "/data/compose/2",
"com.docker.compose.service": "ibsng_core_postgresql",
"com.docker.compose.version": "2.17.2"
},
"StopSignal": "SIGINT"
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "4cf017d6524f81a35b159b1748bd46673cb5ab120e71b1e59c527d4d7825dfc9",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"5432/tcp": null
},
"SandboxKey": "/var/run/docker/netns/4cf017d6524f",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "",
"Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"MacAddress": "",
"Networks": {
"pp_internal_operation": {
"IPAMConfig": null,
"Links": null,
"Aliases": [
"ibsng_core_pg_db",
"ibsng_core_postgresql",
"2e0f18a31dff"
],
"NetworkID": "f412efd77899fb18895697f71feba9838532e34e9c3860c24416af091875067d",
"EndpointID": "bd5bfb54bc36532484fa40c8cf9db6d5e85894cf188d1c9d305180e99e8a7a23",
"Gateway": "172.20.20.1",
"IPAddress": "172.20.20.4",
"IPPrefixLen": 24,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:14:14:04",
"DriverOpts": null
}
}
}
}
]
Error: No such object: volume
root@lsr-deployment:~# docker inspect volume ibsng_syslog
[
{
"CreatedAt": "2023-06-20T14:57:23+03:30",
"Driver": "local",
"Labels": null,
"Mountpoint": "/var/lib/docker/volumes/ibsng_syslog/_data",
"Name": "ibsng_syslog",
"Options": {
"device": "/var/volumes/syslog/data",
"o": "bind",
"type": "none"
},
"Scope": "local"
}
]
Error: No such object: volume
My bad. I wrote docker inspect volume
, even though I should have written docker volume inspect
.
docker inspect
will check all resource types and returns whatever matches. That’s why it returned the inspect output of the container, instead of the volume.
This is the type output I was expecting to see:
This clearly shows that your parameterized the volume creation, to bind a host path as target. The data indeed lives in the host path, and not in its mount point /var/lib/docker/volumes/ibsng_syslog/_data
.
This volume was created with a command like this:
docker volume create --driver local \
--opt type=none \
--opt o=bind \
--opt device=/var/volumes/syslog/data \
ibsng_syslog
Though, your original command was:
This does not create a named volume like above. In this case the data will live directly in /var/lib/docker/volumes/core_pg_db/_data
, like I wrote earlier.
The limitation of your named volume backed by a bind does not come from docker. It comes from the filesystem that you bind.
So your topic boils down to generic Linux questions: “How do I resize a filesystem in Linux” and maybe additional “how do i resize a partition in Linux”. Both are not related to docker. I am sure google will provide plenty of blog posts about that topic.
sorry, my bad this time
I create it with this command:
docker volume create ibsng_core_pg_db --opt type=none --opt device=/var/volumes/postgres/data --opt o=bind
docker volume create ibsng_syslog --opt type=none --opt device=/var/volumes/syslog/data --opt o=bind
root@lsr-deployment:~# docker volume inspect ibsng_core_pg_db
[
{
"CreatedAt": "2023-06-28T16:23:13+03:30",
"Driver": "local",
"Labels": null,
"Mountpoint": "/var/lib/docker/volumes/ibsng_core_pg_db/_data",
"Name": "ibsng_core_pg_db",
"Options": {
"device": "/var/volumes/postgres/data",
"o": "bind",
"type": "none"
},
"Scope": "local"
}
]
root@lsr-deployment:~# docker volume inspect ibsng_syslog
[
{
"CreatedAt": "2023-06-28T11:40:11+03:30",
"Driver": "local",
"Labels": null,
"Mountpoint": "/var/lib/docker/volumes/ibsng_syslog/_data",
"Name": "ibsng_syslog",
"Options": {
"device": "/var/volumes/syslog/data",
"o": "bind",
"type": "none"
},
"Scope": "local"
}
]
as I mentioned before, all settings are the same, and the partition increase successfully in the host machine, but after that when I fill the below folder in the container that is mounted to the host path, the size of the root partition increases
/var/lib/postgresql/data
and it’s not related to the Linux problem
We had plenty of ambiguity in this thread. Your last post is exactly what I was asking for when I asked about the vollume configuration.
It doesn’t add up. Either you are not using the external declared volume in your compose file (your example in post #6 shows that it correctly uses an externally manged volume), or the data inside the container is not written in that path.
You could use docker diff {containername}
to see if data is written into the container filesystem, which would explain why the disk usage increases on the root filesystem (I assume this is what you mean by increased root partition).
root@lsr-deployment:~# docker diff ibsng_core_pg_db
C /run
C /run/postgresql
A /run/postgresql/.s.PGSQL.5432
A /run/postgresql/.s.PGSQL.5432.lock
So nothing is written into the copy-on-write layer of the container filesystem.
I have nothing more to contribute. I hope you find what you are looking for!