Issues running in Docker what am I missing

I am having issues running PowerShell Universal anywhere in Docker.

I have run it from two different servers running Docker on Linux and I get the same error:

docker run --name 'PSU' -it -p 5000:5000 ironmansoftware/universal
Unhandled exception. System.IO.IOException: Input/output error
   at System.IO.Enumeration.FileSystemEnumerator`1.FindNextEntry(Byte* entryBufferPtr, Int32 bufferLength)
   at System.IO.Enumeration.FileSystemEnumerator`1.MoveNext()
   at System.IO.FileSystemWatcher.RunningInstance.AddDirectoryWatchUnlocked(WatchedDirectory parent, String directoryName)
   at System.IO.FileSystemWatcher.RunningInstance.AddDirectoryWatchUnlocked(WatchedDirectory parent, String directoryName)
   at System.IO.FileSystemWatcher.RunningInstance.AddDirectoryWatchUnlocked(WatchedDirectory parent, String directoryName)
   at System.IO.FileSystemWatcher.RunningInstance.AddDirectoryWatchUnlocked(WatchedDirectory parent, String directoryName)
   at System.IO.FileSystemWatcher.RunningInstance..ctor(FileSystemWatcher watcher, SafeFileHandle inotifyHandle, String directoryPath, Boolean includeSubdirectories, NotifyFilters notifyFilters, CancellationToken cancellationToken)
   at System.IO.FileSystemWatcher.StartRaisingEvents()
   at System.IO.FileSystemWatcher.StartRaisingEventsIfNotDisposed()
   at System.IO.FileSystemWatcher.set_EnableRaisingEvents(Boolean value)
   at Microsoft.Extensions.FileProviders.Physical.PhysicalFilesWatcher.TryEnableFileSystemWatcher()
   at Microsoft.Extensions.FileProviders.Physical.PhysicalFilesWatcher.CreateFileChangeToken(String filter)
   at Microsoft.Extensions.FileProviders.PhysicalFileProvider.Watch(String filter)
   at Microsoft.Extensions.Configuration.FileConfigurationProvider.<.ctor>b__1_0()
   at Microsoft.Extensions.Primitives.ChangeToken.OnChange(Func`1 changeTokenProducer, Action changeTokenConsumer)
   at Microsoft.Extensions.Configuration.FileConfigurationProvider..ctor(FileConfigurationSource source)
   at Microsoft.Extensions.Configuration.Json.JsonConfigurationSource.Build(IConfigurationBuilder builder)
   at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build()
   at Microsoft.Extensions.Hosting.HostBuilder.BuildAppConfiguration()
   at Microsoft.Extensions.Hosting.HostBuilder.Build()
   at Universal.Server.Program.<>c__DisplayClass4_0.<Main>b__0(Options o) in D:\a\universal\universal\src\Universal.Server\Program.cs:line 67
   at CommandLine.ParserResultExtensions.WithParsed[T](ParserResult`1 result, Action`1 action)
   at Universal.Server.Program.Main(String[] args) in D:\a\universal\universal\src\Universal.Server\Program.cs:line 48

It seemed like it might be an issue with a volume, so I followed the instructions for creating a persistent data volume and run it again. It starts up and shuts down instantly, I think I am getting the same error but if I use docker logs it says the container doesn’t exist. I know it ran because for a brief second it shows with docker ps

What am I missing?

Hmmmm. I just tried pulling the latest image and it seems to work.

My docker host is Win11 (maybe that’s the difference?).

Yeah, I imagine its not an issue with the image. I have tried older tags and continue to get the same issue. I was thinking it was an SELinux configuration issue where something is being blocked for security reasons. The two installations of Docker I have tried are an individual node running on Docker EE (now Mirantis), and Docker running under Unraid.

Anyway, if someone thinks they might know what’s causing it let me know otherwise Ill update when I find out what’s causing this.

Is your Dockerfile/build repo publicly available? between what is in Dockerhub and the linux install steps I was able to get PowerShell Universal running in a container. I was going to try and build my own image from scratch and I was hoping to reference your Dockerfile.

See below. It’s nothing too fancy and based off of Microsoft’s PowerShell image.

# Docker image file that describes an Ubuntu18.04 image with PowerShell installed from Microsoft APT Repo
ARG fromTag=ubuntu-20.04
ARG imageRepo=mcr.microsoft.com/powershell
FROM ${imageRepo}:${fromTag} AS installer-env

ARG VERSION=1.3.1
ARG PACKAGE_URL=https://imsreleases.blob.core.windows.net/universal/production/${VERSION}/Universal.linux-x64.${VERSION}.zip
ARG DEBIAN_FRONTEND=noninteractive 

# Install dependencies and clean up
RUN apt-get update \
    && apt-get install -y apt-utils 2>&1 | grep -v "debconf: delaying package configuration, since apt-utils is not installed" \
    && apt-get install --no-install-recommends -y \
    # curl is required to grab the Linux package
    curl \
    # less is required for help in powershell
    less \
    # requied to setup the locale
    locales \
    # required for SSL
    ca-certificates \
    gss-ntlmssp \
    # PowerShell remoting over SSH dependencies
    openssh-client \
    unzip \
    libc6-dev \
    tzdata \
    # Download the Linux package and save it
    && echo ${PACKAGE_URL} \
    && curl -sSL ${PACKAGE_URL} -o /tmp/universal.zip \
    && unzip /tmp/universal.zip -d ./home/Universal || : \
    # remove powershell package
    && rm /tmp/universal.zip \
    && chmod +x ./home/Universal/Universal.Server

# Use PowerShell as the default shell
# Use array to avoid Docker prepending /bin/sh -c
EXPOSE 5000
ENTRYPOINT ["./home/Universal/Universal.Server"]
1 Like

I think I figured it out. Based on a post on the Unraid forums certain Docker versions require a WORKDIR to be included in the Docker Build file when using .Net:

https://forums.unraid.net/topic/93461-docker-causing-exception-in-netcore-based-image/

Also this post on the .Net github:

https://github.com/dotnet/dotnet-docker/issues/485

I went from the error you saw above to a file not found error for Universal.Server. After messing with the paths a couple times I got things pointed in the right direction. The last 3 lines I changed to the following:

WORKDIR /home
EXPOSE 5000
ENTRYPOINT ["./Universal/Universal.Server"]

Let me know if you make an update and I can give it a test.

1 Like

This works for me as well! I’ll get our dockerfiles updated for the next release. Thanks for figuring that out!

Update: I got everything working with the new image on my Unraid Server but for the persistent data directions on the forum since the working directory is now /home the entry point needs to be changed in the Dockerfile example.

It is currently set to:

ENTRYPOINT ["./home/Universal/Universal.Server"]

It should be set to:

ENTRYPOINT ["./Universal/Universal.Server"]

Universal Install Docs

Thanks. I updated the docs.