-
Notifications
You must be signed in to change notification settings - Fork 308
Open
Description
Summary
The image name for the docker run
command has to be after all the option flags, else all option flags after postgres
will be interpreted as commands instead.
Where did you see the problem?
Expected behavior
Expected behavior
docker run --name my_postgres -d postgres -e POSTGRES_PASSWORD=mysecretpassword -v my_pgdata:/var/lib/postgresql/data -p 5432:5432
is expected to set the environment variables, instead, they are interpreted as commands.
{
"Id": "4dacbc723a86ec20e8162f42cfa565e4dc6200a49aed32829ddb6e667c131a55",
"Created": "2025-07-25T04:27:07.443229303Z",
"Path": "docker-entrypoint.sh",
"Args": [
"postgres"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 3079,
"ExitCode": 0,
"Error": "",
"StartedAt": "2025-07-25T04:27:07.559146636Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "sha256:85531bd30c3a509dffef26dc8719d3f84c339dbfcf7a327f351037520f0d4df5",
"ResolvConfPath": "/var/lib/docker/containers/4dacbc723a86ec20e8162f42cfa565e4dc6200a49aed32829ddb6e667c131a55/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/4dacbc723a86ec20e8162f42cfa565e4dc6200a49aed32829ddb6e667c131a55/hostname",
"HostsPath": "/var/lib/docker/containers/4dacbc723a86ec20e8162f42cfa565e4dc6200a49aed32829ddb6e667c131a55/hosts",
"LogPath": "/var/lib/docker/containers/4dacbc723a86ec20e8162f42cfa565e4dc6200a49aed32829ddb6e667c131a55/4dacbc723a86ec20e8162f42cfa565e4dc6200a49aed32829ddb6e667c131a55-json.log",
"Name": "/my_postgres",
"RestartCount": 0,
"Driver": "overlay2",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": [
"my_pgdata:/var/lib/postgresql/data"
],
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "bridge",
"PortBindings": {
"5432/tcp": [
{
"HostIp": "",
"HostPort": "5432"
}
]
},
"RestartPolicy": {
"Name": "no",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": null,
"ConsoleSize": [
50,
120
],
"CapAdd": null,
"CapDrop": null,
"CgroupnsMode": "private",
"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",
"Isolation": "",
"CpuShares": 0,
"Memory": 0,
"NanoCpus": 0,
"CgroupParent": "",
"BlkioWeight": 0,
"BlkioWeightDevice": [],
"BlkioDeviceReadBps": [],
"BlkioDeviceWriteBps": [],
"BlkioDeviceReadIOps": [],
"BlkioDeviceWriteIOps": [],
"CpuPeriod": 0,
"CpuQuota": 0,
"CpuRealtimePeriod": 0,
"CpuRealtimeRuntime": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": [],
"DeviceCgroupRules": null,
"DeviceRequests": null,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": null,
"OomKillDisable": null,
"PidsLimit": null,
"Ulimits": [],
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0,
"MaskedPaths": [
"/proc/asound",
"/proc/acpi",
"/proc/interrupts",
"/proc/kcore",
"/proc/keys",
"/proc/latency_stats",
"/proc/timer_list",
"/proc/timer_stats",
"/proc/sched_debug",
"/proc/scsi",
"/sys/firmware",
"/sys/devices/virtual/powercap"
],
"ReadonlyPaths": [
"/proc/bus",
"/proc/fs",
"/proc/irq",
"/proc/sys",
"/proc/sysrq-trigger"
]
},
"GraphDriver": {
"Data": {
"ID": "4dacbc723a86ec20e8162f42cfa565e4dc6200a49aed32829ddb6e667c131a55",
"LowerDir": "/var/lib/docker/overlay2/c549ae5a99b9fe9b415361eda7cad1b58c650e28b3e0ea9611a472e3b9e6e4a2-init/diff:/var/lib/docker/overlay2/a3a8e05134b78fd54d3994433e03bb594b3cfb651b896b98f1a8a23012be8b74/diff:/var/lib/docker/overlay2/e3ae8e81941ff70425ed2ce3a770dda5210a050e710fd505c38cd09a18388744/diff:/var/lib/docker/overlay2/b9b1486233ddd4d5f2a8f42215b5840cd121b0af707529652f0cb1029b35daee/diff:/var/lib/docker/overlay2/edd6c009110d4db3c01134725dcb81e73296a697861f13fb3727ebd8e8d146b7/diff:/var/lib/docker/overlay2/6ecc20cee57b682fe6f5f641cc5845a97b487ee06a1017b8192a613e68f25bd4/diff:/var/lib/docker/overlay2/e1467ad7f5cd08d0e5f7cbbe86ea6bf3383ed26cce3178c8d326cb0397fe218b/diff:/var/lib/docker/overlay2/a850c53320691d89e8d12257d24b750d076c01a49719af02e9fe996e060e9b87/diff:/var/lib/docker/overlay2/cf60fa2536283580473c3ba27ef3f017fa2636b90a16db8cb3ca130e21a77814/diff:/var/lib/docker/overlay2/acafb6ccbb866840913cdc98374c41f7aeb062ebc44ac5cbf46aeb6fdf17fbbf/diff:/var/lib/docker/overlay2/ebff067a772de5b70ee74fef23155e2b9a1efdb0414b6bae3cb2b20652374a34/diff:/var/lib/docker/overlay2/0ac91e0e7aa5daff752ead9ca8d420e839d12bc4e015d74655cb6a956ed13187/diff:/var/lib/docker/overlay2/95a8fccee18f59d88b3c5dbe24712b1fb585f9524e5115903b5d5187e9437922/diff:/var/lib/docker/overlay2/7620a2d718ada34e2e6d870f71cf224afa8d8d29cdf1c40c584ce9d8ea4ea085/diff:/var/lib/docker/overlay2/e638f09751ba68fa9809778dc6f92b9544df2ced022cb8384ba7dbee90310c9a/diff",
"MergedDir": "/var/lib/docker/overlay2/c549ae5a99b9fe9b415361eda7cad1b58c650e28b3e0ea9611a472e3b9e6e4a2/merged",
"UpperDir": "/var/lib/docker/overlay2/c549ae5a99b9fe9b415361eda7cad1b58c650e28b3e0ea9611a472e3b9e6e4a2/diff",
"WorkDir": "/var/lib/docker/overlay2/c549ae5a99b9fe9b415361eda7cad1b58c650e28b3e0ea9611a472e3b9e6e4a2/work"
},
"Name": "overlay2"
},
"Mounts": [
{
"Type": "volume",
"Name": "my_pgdata",
"Source": "/var/lib/docker/volumes/my_pgdata/_data",
"Destination": "/var/lib/postgresql/data",
"Driver": "local",
"Mode": "z",
"RW": true,
"Propagation": ""
}
],
"Config": {
"Hostname": "4dacbc723a86",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"5432/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"POSTGRES_PASSWORD=postgres",
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/postgresql/17/bin",
"GOSU_VERSION=1.17",
"LANG=en_US.utf8",
"PG_MAJOR=17",
"PG_VERSION=17.5-1.pgdg120+1",
"PGDATA=/var/lib/postgresql/data"
],
"Cmd": [
"postgres"
],
"Image": "postgres",
"Volumes": {
"/var/lib/postgresql/data": {}
},
"WorkingDir": "",
"Entrypoint": [
"docker-entrypoint.sh"
],
"OnBuild": null,
"Labels": {},
"StopSignal": "SIGINT"
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "c4bdbe07c7e77e7c2c760fa859cda2f047dd332cda22ca0ffb35b0a67c8cca68",
"SandboxKey": "/var/run/docker/netns/c4bdbe07c7e7",
"Ports": {
"5432/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "5432"
},
{
"HostIp": "::",
"HostPort": "5432"
}
]
},
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "b08397d07ddadf47cba428dfac72073d8682932e87247a53dfaad9a193d70365",
"Gateway": "172.17.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"MacAddress": "96:24:1c:e9:3b:e3",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"MacAddress": "96:24:1c:e9:3b:e3",
"DriverOpts": null,
"GwPriority": 0,
"NetworkID": "8f66178c0d12c62bc5e79f5830c6b93bff79417d25953004257e2d29b6fed0fa",
"EndpointID": "b08397d07ddadf47cba428dfac72073d8682932e87247a53dfaad9a193d70365",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"DNSNames": null
}
}
}
}
Current behavior
As seen in the log and inspection, the password is failed to be set.
2025-07-24 21:44:58.843 | Error: Database is uninitialized and superuser password is not specified.
2025-07-24 21:44:58.843 | You must specify POSTGRES_PASSWORD to a non-empty value for the
2025-07-24 21:44:58.843 | superuser. For example, "-e POSTGRES_PASSWORD=password" on "docker run".
2025-07-24 21:44:58.843 |
2025-07-24 21:44:58.843 | You may also use "POSTGRES_HOST_AUTH_METHOD=trust" to allow all
2025-07-24 21:44:58.843 | connections without a password. This is *not* recommended.
2025-07-24 21:44:58.843 |
2025-07-24 21:44:58.843 | See PostgreSQL documentation about "trust":
2025-07-24 21:44:58.843 | https://www.postgresql.org/docs/current/auth-trust.html
2025-07-24 21:45:06.357 | Error: Database is uninitialized and superuser password is not specified.
2025-07-24 21:45:06.357 | You must specify POSTGRES_PASSWORD to a non-empty value for the
2025-07-24 21:45:06.357 | superuser. For example, "-e POSTGRES_PASSWORD=password" on "docker run".
2025-07-24 21:45:06.357 |
2025-07-24 21:45:06.357 | You may also use "POSTGRES_HOST_AUTH_METHOD=trust" to allow all
2025-07-24 21:45:06.357 | connections without a password. This is *not* recommended.
2025-07-24 21:45:06.357 |
2025-07-24 21:45:06.357 | See PostgreSQL documentation about "trust":
2025-07-24 21:45:06.357 | https://www.postgresql.org/docs/current/auth-trust.html
{
"Id": "d6482247d00a4ed4304ced165548eb4bc1445ef5637aaba873ce5a8e92cdc9bd",
"Created": "2025-07-25T04:44:58.584837548Z",
"Path": "docker-entrypoint.sh",
"Args": [
"-e",
"POSTGRES_PASSWORD=mysecretpassword",
"-v",
"my_pgdata:/var/lib/postgresql/data",
"-p",
"5432:5432"
],
"State": {
"Status": "exited",
"Running": false,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 0,
"ExitCode": 1,
"Error": "",
"StartedAt": "2025-07-25T04:45:06.259979427Z",
"FinishedAt": "2025-07-25T04:45:06.359067427Z"
},
"Image": "sha256:85531bd30c3a509dffef26dc8719d3f84c339dbfcf7a327f351037520f0d4df5",
"ResolvConfPath": "/var/lib/docker/containers/d6482247d00a4ed4304ced165548eb4bc1445ef5637aaba873ce5a8e92cdc9bd/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/d6482247d00a4ed4304ced165548eb4bc1445ef5637aaba873ce5a8e92cdc9bd/hostname",
"HostsPath": "/var/lib/docker/containers/d6482247d00a4ed4304ced165548eb4bc1445ef5637aaba873ce5a8e92cdc9bd/hosts",
"LogPath": "/var/lib/docker/containers/d6482247d00a4ed4304ced165548eb4bc1445ef5637aaba873ce5a8e92cdc9bd/d6482247d00a4ed4304ced165548eb4bc1445ef5637aaba873ce5a8e92cdc9bd-json.log",
"Name": "/my_postgres",
"RestartCount": 0,
"Driver": "overlay2",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": null,
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "bridge",
"PortBindings": {},
"RestartPolicy": {
"Name": "no",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": null,
"ConsoleSize": [
50,
120
],
"CapAdd": null,
"CapDrop": null,
"CgroupnsMode": "private",
"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",
"Isolation": "",
"CpuShares": 0,
"Memory": 0,
"NanoCpus": 0,
"CgroupParent": "",
"BlkioWeight": 0,
"BlkioWeightDevice": [],
"BlkioDeviceReadBps": [],
"BlkioDeviceWriteBps": [],
"BlkioDeviceReadIOps": [],
"BlkioDeviceWriteIOps": [],
"CpuPeriod": 0,
"CpuQuota": 0,
"CpuRealtimePeriod": 0,
"CpuRealtimeRuntime": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": [],
"DeviceCgroupRules": null,
"DeviceRequests": null,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": null,
"OomKillDisable": null,
"PidsLimit": null,
"Ulimits": [],
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0,
"MaskedPaths": [
"/proc/asound",
"/proc/acpi",
"/proc/interrupts",
"/proc/kcore",
"/proc/keys",
"/proc/latency_stats",
"/proc/timer_list",
"/proc/timer_stats",
"/proc/sched_debug",
"/proc/scsi",
"/sys/firmware",
"/sys/devices/virtual/powercap"
],
"ReadonlyPaths": [
"/proc/bus",
"/proc/fs",
"/proc/irq",
"/proc/sys",
"/proc/sysrq-trigger"
]
},
"GraphDriver": {
"Data": {
"ID": "d6482247d00a4ed4304ced165548eb4bc1445ef5637aaba873ce5a8e92cdc9bd",
"LowerDir": "/var/lib/docker/overlay2/59ee7d82cfef676f160d6c1e73a5955fd2fd01daf18d0bffc9fdfaabbfe7bbf4-init/diff:/var/lib/docker/overlay2/a3a8e05134b78fd54d3994433e03bb594b3cfb651b896b98f1a8a23012be8b74/diff:/var/lib/docker/overlay2/e3ae8e81941ff70425ed2ce3a770dda5210a050e710fd505c38cd09a18388744/diff:/var/lib/docker/overlay2/b9b1486233ddd4d5f2a8f42215b5840cd121b0af707529652f0cb1029b35daee/diff:/var/lib/docker/overlay2/edd6c009110d4db3c01134725dcb81e73296a697861f13fb3727ebd8e8d146b7/diff:/var/lib/docker/overlay2/6ecc20cee57b682fe6f5f641cc5845a97b487ee06a1017b8192a613e68f25bd4/diff:/var/lib/docker/overlay2/e1467ad7f5cd08d0e5f7cbbe86ea6bf3383ed26cce3178c8d326cb0397fe218b/diff:/var/lib/docker/overlay2/a850c53320691d89e8d12257d24b750d076c01a49719af02e9fe996e060e9b87/diff:/var/lib/docker/overlay2/cf60fa2536283580473c3ba27ef3f017fa2636b90a16db8cb3ca130e21a77814/diff:/var/lib/docker/overlay2/acafb6ccbb866840913cdc98374c41f7aeb062ebc44ac5cbf46aeb6fdf17fbbf/diff:/var/lib/docker/overlay2/ebff067a772de5b70ee74fef23155e2b9a1efdb0414b6bae3cb2b20652374a34/diff:/var/lib/docker/overlay2/0ac91e0e7aa5daff752ead9ca8d420e839d12bc4e015d74655cb6a956ed13187/diff:/var/lib/docker/overlay2/95a8fccee18f59d88b3c5dbe24712b1fb585f9524e5115903b5d5187e9437922/diff:/var/lib/docker/overlay2/7620a2d718ada34e2e6d870f71cf224afa8d8d29cdf1c40c584ce9d8ea4ea085/diff:/var/lib/docker/overlay2/e638f09751ba68fa9809778dc6f92b9544df2ced022cb8384ba7dbee90310c9a/diff",
"MergedDir": "/var/lib/docker/overlay2/59ee7d82cfef676f160d6c1e73a5955fd2fd01daf18d0bffc9fdfaabbfe7bbf4/merged",
"UpperDir": "/var/lib/docker/overlay2/59ee7d82cfef676f160d6c1e73a5955fd2fd01daf18d0bffc9fdfaabbfe7bbf4/diff",
"WorkDir": "/var/lib/docker/overlay2/59ee7d82cfef676f160d6c1e73a5955fd2fd01daf18d0bffc9fdfaabbfe7bbf4/work"
},
"Name": "overlay2"
},
"Mounts": [
{
"Type": "volume",
"Name": "002826dc1b5934b195a2afd59b5f4c5ddaea59f08b5b6c03a408a42c5645bfbb",
"Source": "/var/lib/docker/volumes/002826dc1b5934b195a2afd59b5f4c5ddaea59f08b5b6c03a408a42c5645bfbb/_data",
"Destination": "/var/lib/postgresql/data",
"Driver": "local",
"Mode": "",
"RW": true,
"Propagation": ""
}
],
"Config": {
"Hostname": "d6482247d00a",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"5432/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/postgresql/17/bin",
"GOSU_VERSION=1.17",
"LANG=en_US.utf8",
"PG_MAJOR=17",
"PG_VERSION=17.5-1.pgdg120+1",
"PGDATA=/var/lib/postgresql/data"
],
"Cmd": [
"-e",
"POSTGRES_PASSWORD=mysecretpassword",
"-v",
"my_pgdata:/var/lib/postgresql/data",
"-p",
"5432:5432"
],
"Image": "postgres",
"Volumes": {
"/var/lib/postgresql/data": {}
},
"WorkingDir": "",
"Entrypoint": [
"docker-entrypoint.sh"
],
"OnBuild": null,
"Labels": {},
"StopSignal": "SIGINT"
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "",
"SandboxKey": "",
"Ports": {},
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "",
"Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"MacAddress": "",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"MacAddress": "",
"DriverOpts": null,
"GwPriority": 0,
"NetworkID": "8f66178c0d12c62bc5e79f5830c6b93bff79417d25953004257e2d29b6fed0fa",
"EndpointID": "",
"Gateway": "",
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"DNSNames": null
}
}
}
}
Screenshots
Expected behavior

Current behavior

Browser / Platform
No response
Additional notes
No response
Metadata
Metadata
Assignees
Labels
No labels