docker / for-win

Bug reports for Docker Desktop for Windows
https://www.docker.com/products/docker#/windows
1.85k stars 283 forks source link

vscode rust devcontainer: cargo build resulting in "failed to link or copy.." #14079

Open dss010101 opened 2 months ago

dss010101 commented 2 months ago

Description

Im not sure if should be reaching out here or vscode for help on this...but i will start here and let me know if im int he wrong location..

image

i have built a vs code devcontainer based on mcr.microsoft.com/devcontainers/rust:1-1-bullseye, running under Docker Desktop on windows 11. I am able to run a basic example using this without any dependencies

i have the following structure (Note: the target and Cargo.lock do not exist until after i attempt a cargo build:

My toml looks like this:

[package]
name = "aipg_client"
version = "0.1.0"
edition = "2021"

#[dependencies]
#tokio-postgres = "0.7.10"

when i do Cargo build or run from command line, i see this:

vscode ➜ /workspaces/aipg_client $ cargo clean
     Removed 19 files, 3.7MiB total
vscode ➜ /workspaces/aipg_client $ cargo build
   Compiling aipg_client v0.1.0 (/workspaces/aipg_client)
warning: error copying object file `/workspaces/aipg_client/target/debug/deps/aipg_client-29a466bd116893b1.2wavitxjlghb5boo.rcgu.o` to incremental directory as `/workspaces/aipg_client/target/debug/incremental/aipg_client-cn2ostj37iq8/s-gw2y4x6qjv-d1xpw0-working/2wavitxjlghb5boo.o`: Operation not permitted (os error 1)

warning: error copying object file `/workspaces/aipg_client/target/debug/deps/aipg_client-29a466bd116893b1.340xt2kclbcozwj5.rcgu.o` to incremental directory as `/workspaces/aipg_client/target/debug/incremental/aipg_client-cn2ostj37iq8/s-gw2y4x6qjv-d1xpw0-working/340xt2kclbcozwj5.o`: Operation not permitted (os error 1)

warning: error copying object file `/workspaces/aipg_client/target/debug/deps/aipg_client-29a466bd116893b1.3nlg3iffbximniu8.rcgu.o` to incremental directory as `/workspaces/aipg_client/target/debug/incremental/aipg_client-cn2ostj37iq8/s-gw2y4x6qjv-d1xpw0-working/3nlg3iffbximniu8.o`: Operation not permitted (os error 1)

warning: error copying object file `/workspaces/aipg_client/target/debug/deps/aipg_client-29a466bd116893b1.57xak5150to06626.rcgu.o` to incremental directory as `/workspaces/aipg_client/target/debug/incremental/aipg_client-cn2ostj37iq8/s-gw2y4x6qjv-d1xpw0-working/57xak5150to06626.o`: Operation not permitted (os error 1)

warning: error copying object file `/workspaces/aipg_client/target/debug/deps/aipg_client-29a466bd116893b1.ele9p2lo4vgyfma.rcgu.o` to incremental directory as `/workspaces/aipg_client/target/debug/incremental/aipg_client-cn2ostj37iq8/s-gw2y4x6qjv-d1xpw0-working/ele9p2lo4vgyfma.o`: Operation not permitted (os error 1)

warning: error copying object file `/workspaces/aipg_client/target/debug/deps/aipg_client-29a466bd116893b1.eyyxtxgek58rknf.rcgu.o` to incremental directory as `/workspaces/aipg_client/target/debug/incremental/aipg_client-cn2ostj37iq8/s-gw2y4x6qjv-d1xpw0-working/eyyxtxgek58rknf.o`: Operation not permitted (os error 1)

warning: `aipg_client` (bin "aipg_client") generated 6 warnings
error: failed to link or copy `/workspaces/aipg_client/target/debug/deps/aipg_client-29a466bd116893b1` to `/workspaces/aipg_client/target/debug/aipg_client`

Caused by:
  Operation not permitted (os error 1)

i checked these folders and they are all r/w. What am i doing wrong?

Reproduce

  1. Create a vscode dev container: CTRL+SHIFT+P -> devcontainer:new -> rust
  2. Note: i jused a Dockerfile + Docker Compose along with .devcontainer.json. but the issue is reproducible with just a .devcontainer.json file
  3. Install rust analyzer extension in the container
  4. from bash terminal: cargo new test
  5. run cargo build twice

Expected behavior

No response

docker version

Client:
 Cloud integration: v1.0.35+desktop.13
 Version:           26.0.0
 API version:       1.45
 Go version:        go1.21.8
 Git commit:        2ae903e
 Built:             Wed Mar 20 15:18:56 2024
 OS/Arch:           windows/amd64
 Context:           default

Server: Docker Desktop 4.29.0 (145265)
 Engine:
  Version:          26.0.0
  API version:      1.45 (minimum version 1.24)
  Go version:       go1.21.8
  Git commit:       8b79278
  Built:            Wed Mar 20 15:18:01 2024
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.28
  GitCommit:        ae07eda36dd25f8a1b98dfbf587313b99c0190bb
 runc:
  Version:          1.1.12
  GitCommit:        v1.1.12-0-g51d5e94
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

docker info

Client:
 Version:    26.0.0
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.13.1-desktop.1
    Path:     C:\Program Files\Docker\cli-plugins\docker-buildx.exe
  compose: Docker Compose (Docker Inc.)
    Version:  v2.26.1-desktop.1
    Path:     C:\Program Files\Docker\cli-plugins\docker-compose.exe
  debug: Get a shell into any image or container. (Docker Inc.)
    Version:  0.0.27
    Path:     C:\Program Files\Docker\cli-plugins\docker-debug.exe
  dev: Docker Dev Environments (Docker Inc.)
    Version:  v0.1.2
    Path:     C:\Program Files\Docker\cli-plugins\docker-dev.exe
  extension: Manages Docker extensions (Docker Inc.)
    Version:  v0.2.23
    Path:     C:\Program Files\Docker\cli-plugins\docker-extension.exe
  feedback: Provide feedback, right in your terminal! (Docker Inc.)
    Version:  v1.0.4
    Path:     C:\Program Files\Docker\cli-plugins\docker-feedback.exe
  init: Creates Docker-related starter files for your project (Docker Inc.)
    Version:  v1.1.0
    Path:     C:\Program Files\Docker\cli-plugins\docker-init.exe
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.)
    Version:  0.6.0
    Path:     C:\Program Files\Docker\cli-plugins\docker-sbom.exe
  scout: Docker Scout (Docker Inc.)
    Version:  v1.6.3
    Path:     C:\Program Files\Docker\cli-plugins\docker-scout.exe

Server:
 Containers: 3
  Running: 2
  Paused: 0
  Stopped: 1
 Images: 28
 Server Version: 26.0.0
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 Swarm: inactive
 Runtimes: runc io.containerd.runc.v2
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: ae07eda36dd25f8a1b98dfbf587313b99c0190bb
 runc version: v1.1.12-0-g51d5e94
 init version: de40ad0
 Security Options:
  seccomp
   Profile: unconfined
 Kernel Version: 5.15.146.1-microsoft-standard-WSL2
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 12
 Total Memory: 7.693GiB
 Name: docker-desktop
 ID: 06f9f152-af5c-4d3d-9a52-040ae346c0c5
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 No Proxy: hubproxy.docker.internal
 Labels:
  com.docker.desktop.address=npipe://\\.\pipe\docker_cli
 Experimental: false
 Insecure Registries:
  hubproxy.docker.internal:5555
  127.0.0.0/8
 Live Restore Enabled: false

WARNING: No blkio throttle.read_bps_device support
WARNING: No blkio throttle.write_bps_device support
WARNING: No blkio throttle.read_iops_device support
WARNING: No blkio throttle.write_iops_device support
WARNING: daemon is not using the default seccomp profile

Diagnostics ID

C4BAD374-B462-4BF5-90BC-244E3E1841E5/20240517055357

Additional Info

No response

dss010101 commented 2 months ago

though i dont know if its relevant here i are my docker file and docker-compose: docker file:

FROM mcr.microsoft.com/devcontainers/rust:1-1-bullseye as aipg_client_base
ENV TZ=America/New_York

ARG ENV
ARG USER_ID
ARG GROUP_ID
ARG USER_NAME
ARG APP_HOME="/apps/aipg_client_base"
RUN echo "env: $ENV, user: $USER_NAME, user_id: $USER_ID, app_home: $APP_HOME"

RUN apt-get update && apt-get -y install acl iputils-ping less libpq-dev nano postgresql-client sudo

RUN groupadd -g $GROUP_ID -o $USER_NAME
RUN useradd -m -s /bin/bash -u $USER_ID -g $GROUP_ID $USER_NAME

FROM aipg_client_base as aipg_client_local

#attempt at handling this target folder issue...
RUN mkdir -p /workspaces/aipg_client/target
RUN chown -R vscode:vscode /workspaces/aipg_client/target
RUN chmod -R 777 /workspaces/aipg_client/target

docker-compose:

networks:
  aipg_client_net:
    driver: bridge

services:
  aipg_client:
    container_name: aipg_client_${ENV}
    image: "aipg_client:${VERSION}"
    build:
      context: ..
      dockerfile: .devcontainer/Dockerfile
      target: aipg_client_local
      args:
        ENV: ${ENV:-local}
        USER_ID: ${USER_ID:-1000}
        GROUP_ID: ${GROUP_ID:-1000}
        USER_NAME: ${USER_NAME}
      shm_size: '2gb'
    env_file:
      - ./.env
    volumes:
      - ../..:/workspaces
      - ~/.ssh:/home/${USER_NAME}/.ssh
      - //var/run/docker.sock:/var/run/docker.sock
    command: sleep infinity
    shm_size: 0.94gb
    ports: 
      - "${SVC_PORT}:5000"    
    networks:
      - aipg_client_net

.env file:

VERSION=local
ENV=local
USER_ID=197609
#USER_ID=1001
GROUP_ID=1000
USER_NAME=user1
SVC_PORT=6000

if i add a .cargo/config.toml with the target anywhere outside my project workspace, it seems to work fine

[build]
target-dir = "/tmp/target"

But of course that means anytime i restart/rebuild the container, i have to rebuild the project/binaries. which makes it not seem like a good solution

dss010101 commented 2 months ago

Anyone with any advice on how to go about resolving this?