rancher-sandbox / rancher-desktop

Container Management and Kubernetes on the Desktop
https://rancherdesktop.io
Apache License 2.0
5.96k stars 281 forks source link

Getting Permission Denied in Container #6200

Open ryanomor opened 10 months ago

ryanomor commented 10 months ago

Actual Behavior

After creating and running my containers using docker compose up -d, when I try connecting to it, I get permission issues. I open the container logs with docker container logs $CONTAINER_ID and get multiple lines of chown: changing ownership of '/var/lib/postgresql/data/base/558180/558738': Permission denied

Steps to Reproduce

Create a docker-compose.yml that has the same config as below. Then run docker compose up -d and try connecting to the container and view the logs:

version: '3.1'

services:

  postgres:
    image: postgres:11
    restart: always
    command: postgres -c 'max_connections=200'
    environment:
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      POSTGRES_USER: ${POSTGRES_USER}
    volumes:
      - ${VOLUMES_ROOT}/postgres/data:/var/lib/postgresql/data
    ports:
      - ${POSTGRES_PORT}:5432

Result

Can not connect to the port exposed by the container. And when I get the logs of the container, I get multiple chown permission denied errors

Expected Behavior

Can connect to the port exposed by container. No permission denied logs in container

Additional Information

No response

Rancher Desktop Version

1.10.0

Rancher Desktop K8s Version

v1.27.7

Which container engine are you using?

moby (docker cli)

What operating system are you using?

macOS

Operating System / Build Version

macOS Monterey 12.7

What CPU architecture are you using?

x64

Linux only: what package format did you use to install Rancher Desktop?

None

Windows User Only

No response

jandubois commented 10 months ago

@ryanomor suggested on Slack it may be the same issue as #1209

ryanomor commented 10 months ago

Turns out volume mounting with docker compose in both Docker and Rancher Desktops has some issues.

I followed the instructions in the comment in the above issue thread: https://github.com/rancher-sandbox/rancher-desktop/issues/1209#issuecomment-1370181132

After adding the override config, I restarted rancher: rdctl shutdown, then rdctl start (you may have to reset the context back to rancher desktop: docker context use rancher-desktop)

I ran docker compose up and all my containers seemed to be running with the right permissions except for my postgres one. So I just manually ran it without using compose and it worked: docker run --name postgres11 -e POSTGRES_USER=$PG_USER -e POSTGRES_PASSWORD=$PG_PASS -p 5432:5432 --detach postgres:11

jandubois commented 10 months ago

Thanks for the update!

I would like to keep this issue open for a bit, to see if e.g. there is something we can add to our docs about it.