Dotnet-docker: Cannot get dotnet ef database update to work

Created on 5 Feb 2020  路  2Comments  路  Source: dotnet/dotnet-docker

Steps to reproduce the issue

1.Please build this dockerfile

FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster
WORKDIR /app

RUN dotnet tool install --global dotnet-ef
RUN export PATH="$PATH:/root/.dotnet/tools"
RUN dotnet ef database update

Expected behavior

A docker image with dotnet ef database update working

Actual behavior

Could not execute because the specified command or file was not found.
Possible reasons for this include:
  * You misspelled a built-in dotnet command.
  * You intended to execute a .NET Core program, but dotnet-ef does not exist.
  * You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
The command '/bin/sh -c dotnet ef database update' returned a non-zero code: 1

Additional information (e.g. issue happens only occasionally)

Output of docker version

Client: Docker Engine - Community
 Version:           19.03.5
 API version:       1.40
 Go version:        go1.12.12
 Git commit:        633a0ea
 Built:             Wed Nov 13 07:22:37 2019
 OS/Arch:           windows/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.5
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.12
  Git commit:       633a0ea
  Built:            Wed Nov 13 07:29:19 2019
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.2.10
  GitCommit:        b34a5c8af56e510852c35414db4c1f4fa6172339
 runc:
  Version:          1.0.0-rc8+dev
  GitCommit:        3e425f80a8c931f88e6d94a8c831b9d5aa481657
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

Output of docker info

Client:
 Debug Mode: false

Server:
 Containers: 9
  Running: 0
  Paused: 0
  Stopped: 9
 Images: 69
 Server Version: 19.03.5
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: b34a5c8af56e510852c35414db4c1f4fa6172339
 runc version: 3e425f80a8c931f88e6d94a8c831b9d5aa481657
 init version: fec3683
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 4.9.184-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 4
 Total Memory: 15.4GiB
 Name: docker-desktop
 ID: LM3E:KZUN:6MHQ:IF2F:AOS6:GGOP:B3K6:CMNL:A633:4YIL:TOHQ:5MPI
 Docker Root Dir: /var/lib/docker
 Debug Mode: true
  File Descriptors: 29
  Goroutines: 44
  System Time: 2020-02-05T13:02:34.6491943Z
  EventsListeners: 1
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
 Product License: Community Engine
question

Most helpful comment

A shell session isn't maintained across Docker layers. For that reason, exporting the path with RUN export PATH="$PATH:/root/.dotnet/tools" doesn't actually yield what you want in subsequent layers. The value of PATH remains unchanged. Instead, you should replace that line with the following: ENV PATH="${PATH}:/root/.dotnet/tools".

All 2 comments

A shell session isn't maintained across Docker layers. For that reason, exporting the path with RUN export PATH="$PATH:/root/.dotnet/tools" doesn't actually yield what you want in subsequent layers. The value of PATH remains unchanged. Instead, you should replace that line with the following: ENV PATH="${PATH}:/root/.dotnet/tools".

Closing per the guidance provided. Feel free to continue discussing.

Was this page helpful?
0 / 5 - 0 ratings