Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

colima is overwritting ~/.lima/colima/lima.yam during startup #118

Closed
phaus opened this issue Jan 14, 2022 · 11 comments
Closed

colima is overwritting ~/.lima/colima/lima.yam during startup #118

phaus opened this issue Jan 14, 2022 · 11 comments

Comments

@phaus
Copy link

phaus commented Jan 14, 2022

I did update the ~/.lima/colima/lima.yam to have a write-able access to my userfolder:


mounts:
    - location: /Users/myuser/
      writable: true

However, after restarting colima, the config is always reset to writable: false.
I also wounder why it is false in the first place, since I created the colima VM with

colima start --mount $HOME:/Users/myuser:w

This issues is blocking me, from migrating from docker for desktop to colima, since I need to have foders within my home user path writable (e.g. for postgres containers).

@phaus
Copy link
Author

phaus commented Jan 14, 2022

I found a line in the code, that I don't understand:
https://github.com/abiosoft/colima/blob/main/environment/vm/lima/yaml.go#L76

Here the flag writable seems to be set to false for all (Cache?) Folders? 🤔

@abiosoft
Copy link
Owner

@phaus what version are you on?

Do not worry about volume mounts as it should simply work if you're on version >=0.3.0. Since 0.3.0, colima defaults to mountable volume to your home directory.

If you still prefer to manually mount volumes, your syntax is wrong. It should be /Users/myuser:w or $HOME:/w.

@abiosoft
Copy link
Owner

However, after restarting colima, the config is always reset to writable: false

Yeah, Colima dynamic generates the lima config on startup. Modify the config has no effect except you use Lima override.

I found a line in the code, that I don't understand:
https://github.com/abiosoft/colima/blob/main/environment/vm/lima/yaml.go#L76

Here the flag writable seems to be set to false for all (Cache?) Folders? 🤔

That is the expectable behaviour, the cache directory is only used for assets download via the host and does not need to be writable

@phaus
Copy link
Author

phaus commented Jan 14, 2022

I am trying to run a docker container as I am doing it with docker for mac:

docker run -d \
    -v $PWD/work:/work \
    -v $PWD/data:/data \
    -v $PWD/tmp/db-data:/var/lib/postgresql/data \
    -e POSTGRES_USER=postgres \
    -e POSTGRES_PASSWORD=password \
    -e POSTGRES_DB=database \
    -e PGDATA=/var/lib/postgresql/data \
    --name db-host \
   ghcr.io/baosystems/postgis:13-3.1

PWD points to /Users/myuser/GIT/project/data-importer - I am not able to start this container, since it cannot write to the mounted folder.

docker: Error response from daemon: error while creating mount source path '/Users/myuser/GIT/project/data-importer/tmp/db-data': chown /Users/myuser/GIT/project/data-importer/tmp/db-data: permission denied.
ERRO[0000] error waiting for container: context canceled

In both cases: with a default colima setup and mounting it manually.
I am also not able to touch a file in this folder, if I am within the colima VM via ssh.

Am I am doing something wrong? 🤔

@abiosoft
Copy link
Owner

Does this work?

docker run -d \
    -v $PWD/work:/work \
    -v $PWD/data:/data \
    -v $PWD/tmp/db-data:/var/lib/postgresql \
    -e POSTGRES_USER=postgres \
    -e POSTGRES_PASSWORD=password \
    -e POSTGRES_DB=database \
    -e PGDATA=/var/lib/postgresql/data \
    --name db-host \
   ghcr.io/baosystems/postgis:13-3.1

@phaus
Copy link
Author

phaus commented Jan 14, 2022

Similar error:

docker: Error response from daemon: error while creating mount source path '/Users/myuser/GIT/project/data-importer/tmp/db-data': chown /Users/myuser/GIT/project/data-importer/tmp/db-data: permission denied.

@abiosoft
Copy link
Owner

I believe it is related to this #70 (comment) and #83.

As a workaround since $PWD/tmp/db-data is just a cache directory, why not simply use docker volume for that? Or you need to persist it on the host?

docker run -d \
    -v $PWD/work:/work \
    -v $PWD/data:/data \
    -v db-data-cache:/var/lib/postgresql/data \
    -e POSTGRES_USER=postgres \
    -e POSTGRES_PASSWORD=password \
    -e POSTGRES_DB=database \
    -e PGDATA=/var/lib/postgresql/data \
    --name db-host \
   ghcr.io/baosystems/postgis:13-3.1

@phaus
Copy link
Author

phaus commented Jan 14, 2022

thx for the hint.
But are you sure, that not /tmpis the cache directory or even $HOME/tmp?
$PWD/tmp translates to /Users/myuser/GIT/project/data-importer/tmp

I am not able to use docker volumes, since in $PWD/work there are some files I need to have within the container during operation, $PWD/data the the output folder for the container.

@abiosoft
Copy link
Owner

If you observe the error message #118 (comment), the only issue is with the $PWD/tmp/db-data directory because the postgres container is trying chown on it.

You can make only that a docker volume as I specified here #118 (comment).

@phaus
Copy link
Author

phaus commented Jan 14, 2022

Then I can still not write any files from my docker container into /data.
I am also not able to change the user of the docker process to the macos uid and gid, since then the postgres doesn't startup.
IMHO The uid 0 should be able to write data to mounted folders. That is the default behaviour of a docker host and it is a common procedure within a DEV development to have a shared folder.

@phaus
Copy link
Author

phaus commented Jan 15, 2022

So I guess this permission issue is related to lima-vm/lima#231 - I will track it there and close it here :-)

@phaus phaus closed this as completed Jan 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants