5
30
Fork
You've already forked nvim-dev-container
3

attach_mounts option is uneffective #97

Open
opened 2023年09月12日 13:28:55 +02:00 by wandering-tales · 4 comments

Version

  • Revision dc20f63474bb68b88004da99d5bbaa0beffb72e3
  • Neovim 0.9.2 on Mac OS X 13.5.2

Describe the bug
It seems the attach_mounts option is uneffective. Neovim configuration, data and state are not mounted in the devcontainer.
This is my current configuration:

require('devcontainer').setup {
 autocommands = {
 -- do not automatically start containers when devcontainer.json is available
 init = false,
 -- automatically remove any started containers and any built images when exiting vim
 clean = true,
 -- automatically restart containers when devcontainer.json file is updated
 update = true,
 },
 log_level = "debug",
 attach_mounts = {
 always = true,
 neovim_config = {
 -- enables mounting local config to /root/.config/nvim in container
 enabled = true,
 -- makes mount readonly in container
 options = { "readonly" }
 },
 neovim_data = {
 -- enables mounting local data to /root/.local/share/nvim in container
 enabled = true,
 -- no options by default
 options = {}
 },
 -- Only useful if using neovim 0.8.0+
 neovim_state = {
 -- enables mounting local state to /root/.local/state/nvim in container
 enabled = true,
 -- no options by default
 options = {}
 },
 },
}

I have tried both using the DevcontainerStart command and the start_auto LUA function as follows:

:lua require("devcontainer.commands").start_auto()

Expected behavior
I expect the ~/.config/nvim, ~/.local/share/nvim, and ~/.local/state/nvim directories on my local machine to be respectively mounted in /root/.config/nvim, /root/.local/share/nvim, and /root/.local/state/nvim directories within the dev container.

Provide logs if possible
As you can see I have also tried to increase the logs verbosity, but I do not see anything useful:

[ERROR Tue Sep 12 13:01:55 2023]: "docker-compose" command ({ "-f", "/Users/michelecardone/Develop/NozomiNetworks/tori/.devcontainer/../docker-compose.yml", "-f", "/Users/michelecardone/Develop/NozomiNetworks/tori/.devcontainer/docker-compose.yml", "up", "-d" }): " Network tori_default Creating\n"
[ERROR Tue Sep 12 13:01:55 2023]: "docker-compose" command ({ "-f", "/Users/michelecardone/Develop/NozomiNetworks/tori/.devcontainer/../docker-compose.yml", "-f", "/Users/michelecardone/Develop/NozomiNetworks/tori/.devcontainer/docker-compose.yml", "up", "-d" }): " Network tori_default Created\n"
[ERROR Tue Sep 12 13:01:55 2023]: "docker-compose" command ({ "-f", "/Users/michelecardone/Develop/NozomiNetworks/tori/.devcontainer/../docker-compose.yml", "-f", "/Users/michelecardone/Develop/NozomiNetworks/tori/.devcontainer/docker-compose.yml", "up", "-d" }): " Container tori-test-1 Creating\n Container tori-dev-1 Creating\n Container tori-n2os-1 Creating\n"
[ERROR Tue Sep 12 13:01:55 2023]: "docker-compose" command ({ "-f", "/Users/michelecardone/Develop/NozomiNetworks/tori/.devcontainer/../docker-compose.yml", "-f", "/Users/michelecardone/Develop/NozomiNetworks/tori/.devcontainer/docker-compose.yml", "up", "-d" }): " Container tori-test-1 Created\n"
[ERROR Tue Sep 12 13:01:55 2023]: "docker-compose" command ({ "-f", "/Users/michelecardone/Develop/NozomiNetworks/tori/.devcontainer/../docker-compose.yml", "-f", "/Users/michelecardone/Develop/NozomiNetworks/tori/.devcontainer/docker-compose.yml", "up", "-d" }): " Container tori-dev-1 Created\n Container tori-n2os-1 Created\n"
[ERROR Tue Sep 12 13:01:55 2023]: "docker-compose" command ({ "-f", "/Users/michelecardone/Develop/NozomiNetworks/tori/.devcontainer/../docker-compose.yml", "-f", "/Users/michelecardone/Develop/NozomiNetworks/tori/.devcontainer/docker-compose.yml", "up", "-d" }): " Container tori-test-1 Starting\n Container tori-n2os-1 Starting\n"
[ERROR Tue Sep 12 13:01:55 2023]: "docker-compose" command ({ "-f", "/Users/michelecardone/Develop/NozomiNetworks/tori/.devcontainer/../docker-compose.yml", "-f", "/Users/michelecardone/Develop/NozomiNetworks/tori/.devcontainer/docker-compose.yml", "up", "-d" }): " Container tori-dev-1 Starting\n"
[ERROR Tue Sep 12 13:01:55 2023]: "docker-compose" command ({ "-f", "/Users/michelecardone/Develop/NozomiNetworks/tori/.devcontainer/../docker-compose.yml", "-f", "/Users/michelecardone/Develop/NozomiNetworks/tori/.devcontainer/docker-compose.yml", "up", "-d" }): " Container tori-test-1 Started\n"
[ERROR Tue Sep 12 13:01:55 2023]: "docker-compose" command ({ "-f", "/Users/michelecardone/Develop/NozomiNetworks/tori/.devcontainer/../docker-compose.yml", "-f", "/Users/michelecardone/Develop/NozomiNetworks/tori/.devcontainer/docker-compose.yml", "up", "-d" }): " Container tori-n2os-1 Started\n"
[ERROR Tue Sep 12 13:01:55 2023]: "docker-compose" command ({ "-f", "/Users/michelecardone/Develop/NozomiNetworks/tori/.devcontainer/../docker-compose.yml", "-f", "/Users/michelecardone/Develop/NozomiNetworks/tori/.devcontainer/docker-compose.yml", "up", "-d" }): " Container tori-dev-1 Started\n"

It seems no mount option is passed to compose.

**Version** - Revision `dc20f63474bb68b88004da99d5bbaa0beffb72e3` - Neovim 0.9.2 on Mac OS X 13.5.2 **Describe the bug** It seems the `attach_mounts` option is uneffective. Neovim configuration, data and state are not mounted in the devcontainer. This is my current configuration: ```lua require('devcontainer').setup { autocommands = { -- do not automatically start containers when devcontainer.json is available init = false, -- automatically remove any started containers and any built images when exiting vim clean = true, -- automatically restart containers when devcontainer.json file is updated update = true, }, log_level = "debug", attach_mounts = { always = true, neovim_config = { -- enables mounting local config to /root/.config/nvim in container enabled = true, -- makes mount readonly in container options = { "readonly" } }, neovim_data = { -- enables mounting local data to /root/.local/share/nvim in container enabled = true, -- no options by default options = {} }, -- Only useful if using neovim 0.8.0+ neovim_state = { -- enables mounting local state to /root/.local/state/nvim in container enabled = true, -- no options by default options = {} }, }, } ``` I have tried both using the `DevcontainerStart` command and the `start_auto` LUA function as follows: ``` :lua require("devcontainer.commands").start_auto() ``` **Expected behavior** I expect the `~/.config/nvim`, `~/.local/share/nvim`, and `~/.local/state/nvim` directories on my local machine to be respectively mounted in `/root/.config/nvim`, `/root/.local/share/nvim`, and `/root/.local/state/nvim` directories within the dev container. **Provide logs if possible** As you can see I have also tried to increase the logs verbosity, but I do not see anything useful: ``` [ERROR Tue Sep 12 13:01:55 2023]: "docker-compose" command ({ "-f", "/Users/michelecardone/Develop/NozomiNetworks/tori/.devcontainer/../docker-compose.yml", "-f", "/Users/michelecardone/Develop/NozomiNetworks/tori/.devcontainer/docker-compose.yml", "up", "-d" }): " Network tori_default Creating\n" [ERROR Tue Sep 12 13:01:55 2023]: "docker-compose" command ({ "-f", "/Users/michelecardone/Develop/NozomiNetworks/tori/.devcontainer/../docker-compose.yml", "-f", "/Users/michelecardone/Develop/NozomiNetworks/tori/.devcontainer/docker-compose.yml", "up", "-d" }): " Network tori_default Created\n" [ERROR Tue Sep 12 13:01:55 2023]: "docker-compose" command ({ "-f", "/Users/michelecardone/Develop/NozomiNetworks/tori/.devcontainer/../docker-compose.yml", "-f", "/Users/michelecardone/Develop/NozomiNetworks/tori/.devcontainer/docker-compose.yml", "up", "-d" }): " Container tori-test-1 Creating\n Container tori-dev-1 Creating\n Container tori-n2os-1 Creating\n" [ERROR Tue Sep 12 13:01:55 2023]: "docker-compose" command ({ "-f", "/Users/michelecardone/Develop/NozomiNetworks/tori/.devcontainer/../docker-compose.yml", "-f", "/Users/michelecardone/Develop/NozomiNetworks/tori/.devcontainer/docker-compose.yml", "up", "-d" }): " Container tori-test-1 Created\n" [ERROR Tue Sep 12 13:01:55 2023]: "docker-compose" command ({ "-f", "/Users/michelecardone/Develop/NozomiNetworks/tori/.devcontainer/../docker-compose.yml", "-f", "/Users/michelecardone/Develop/NozomiNetworks/tori/.devcontainer/docker-compose.yml", "up", "-d" }): " Container tori-dev-1 Created\n Container tori-n2os-1 Created\n" [ERROR Tue Sep 12 13:01:55 2023]: "docker-compose" command ({ "-f", "/Users/michelecardone/Develop/NozomiNetworks/tori/.devcontainer/../docker-compose.yml", "-f", "/Users/michelecardone/Develop/NozomiNetworks/tori/.devcontainer/docker-compose.yml", "up", "-d" }): " Container tori-test-1 Starting\n Container tori-n2os-1 Starting\n" [ERROR Tue Sep 12 13:01:55 2023]: "docker-compose" command ({ "-f", "/Users/michelecardone/Develop/NozomiNetworks/tori/.devcontainer/../docker-compose.yml", "-f", "/Users/michelecardone/Develop/NozomiNetworks/tori/.devcontainer/docker-compose.yml", "up", "-d" }): " Container tori-dev-1 Starting\n" [ERROR Tue Sep 12 13:01:55 2023]: "docker-compose" command ({ "-f", "/Users/michelecardone/Develop/NozomiNetworks/tori/.devcontainer/../docker-compose.yml", "-f", "/Users/michelecardone/Develop/NozomiNetworks/tori/.devcontainer/docker-compose.yml", "up", "-d" }): " Container tori-test-1 Started\n" [ERROR Tue Sep 12 13:01:55 2023]: "docker-compose" command ({ "-f", "/Users/michelecardone/Develop/NozomiNetworks/tori/.devcontainer/../docker-compose.yml", "-f", "/Users/michelecardone/Develop/NozomiNetworks/tori/.devcontainer/docker-compose.yml", "up", "-d" }): " Container tori-n2os-1 Started\n" [ERROR Tue Sep 12 13:01:55 2023]: "docker-compose" command ({ "-f", "/Users/michelecardone/Develop/NozomiNetworks/tori/.devcontainer/../docker-compose.yml", "-f", "/Users/michelecardone/Develop/NozomiNetworks/tori/.devcontainer/docker-compose.yml", "up", "-d" }): " Container tori-dev-1 Started\n" ``` It seems no mount option is passed to compose.

Thank you for reporting this.

Unfortunately, docker-compose CLI does not support passing extra arguments when starting individual containers. I realized that podman-compose does support this, so I will add that to this plugin, but that still leaves this unsolved for anybody using docker.

I would definitely like to avoid re-implementing compose stuff and manually parsing the compose file and starting services. I will try to figure a solution out for docker users too, but right now, I will just add it for podman-compose since it should be fairly straightforward.

Thank you for reporting this. Unfortunately, `docker-compose` CLI does not support passing extra arguments when starting individual containers. I realized that `podman-compose` does support this, so I will add that to this plugin, but that still leaves this unsolved for anybody using `docker`. I would definitely like to avoid re-implementing compose stuff and manually parsing the compose file and starting services. I will try to figure a solution out for `docker` users too, but right now, I will just add it for `podman-compose` since it should be fairly straightforward.

Thanks for the reply 🙂 I didn't have time to check on this lately.

However, I am still curious about in which conditions the attach_mounts option currently work.

Thanks for the reply 🙂 I didn't have time to check on this lately. However, I am still curious about in which conditions the `attach_mounts` option currently work.

Currently it is only effective when working with single container (not with compose). I haven't yet implemented this for podman-compose and for docker compose I don't think I will be able to.

Currently it is only effective when working with single container (not with compose). I haven't yet implemented this for `podman-compose` and for `docker compose` I don't think I will be able to.

Gotcha! Thanks.

Gotcha! Thanks.
Sign in to join this conversation.
No Branch/Tag specified
main
feature/netman-integration
improvement/container-api
0.2.0
0.1.1
0.1.0
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
esensar/nvim-dev-container#97
Reference in a new issue
esensar/nvim-dev-container
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?