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

.NetCore SDK 3.1 Docker not support ENV LC_ALL and LANG (2.1 is support) #5225

Open
uopeydel opened this issue Sep 18, 2020 · 5 comments
Open

Comments

@uopeydel
Copy link

Issue Title

Those environment variables can't use in docker.

# ENV LANG th_TH.UTF-8  
# ENV LC_ALL th_TH.UTF-8 

From base image mcr.microsoft.com/dotnet/core/sdk:3.1 previous I use 2.1 it work fine.

Step 1

https://github.com/uopeydel/testdb

use this project step test is run command

docker build --pull --rm -f "dockerfile" -t testdb:latest "."

docker run -d -p 1144:443/tcp -p 1188:80/tcp testdb:latest

and go to url

http://localhost:1188/api/Values/GetData

It will show you error message

An unhandled exception occurred while processing the request.
SqlException: Invalid column name '__data_0'.
Microsoft.Data.SqlClient.SqlCommand+<>c.<ExecuteDbDataReaderAsync>b__164_0(Task<SqlDataReader> result)

Then comment line below in "dockerfile"

# ENV LANG th_TH.UTF-8  
# ENV LC_ALL th_TH.UTF-8 

then try to build docker and run again it will be work fine.

** please change ConnectionStrings before test

Step 2

I tried to create new docker file pushed today name "dockerfile.v2"

You can run it by command

docker build --pull --rm -f "dockerfile.v2" -t testdb:latest "."

If I have 2 line of this code

 ENV LC_ALL th_TH.UTF-8    
 ENV LANG th_TH.UTF-8   

And run this command

docker run -p 1144:443/tcp -p 1188:80/tcp testdb:latest

It will show this error message

watch : Polling file watcher is enabled
watch : Started
watch : System.ArgumentException: An item with the same key has already been added. Key: /app/FirstCodeDb/Controllers/
   at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
   at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
   at Microsoft.DotNet.Watcher.Internal.FileWatcher.AddDirectoryWatcher(String directory)
   at Microsoft.DotNet.Watcher.Internal.FileSetWatcher.GetChangedFileAsync(CancellationToken cancellationToken, Action startedWatching)
   at Microsoft.DotNet.Watcher.DotNetWatcher.WatchAsync(ProcessSpec processSpec, IFileSetFactory fileSetFactory, CancellationToken cancellationToken)
   at Microsoft.DotNet.Watcher.Program.MainInternalAsync(IReporter reporter, String project, ICollection`1 args, CancellationToken cancellationToken)
   at Microsoft.DotNet.Watcher.Program.RunAsync(String[] args)
watch : An unexpected error occurred

If I remove this 2 line

 ENV LC_ALL th_TH.UTF-8    
 ENV LANG th_TH.UTF-8   

It will work fine.

@carlossanlop
Copy link
Member

@MichaelSimons any chance you could help with this issue?

@uopeydel
Copy link
Author

image

I don't think it happen because docker , I tried run it on linux server it also show an error.

@MichaelSimons
Copy link
Member

@uopeydel , If I am following correctly, you have encountered two different issues. It would be helpful if you logged each problem as a separate issue. This makes each issue more clear. It also helps get the right people involved to diagnose and respond to each issue.

Step #1 - I would suggest debugging into this further. What SQL query is being executed? Does the query match the data schema? Something appears mis-configured in the DB versus what is in the code.

Step #2 - As noted this happens outside of Docker. @carlossanlop, please loop in the owners of dotnet watch to help with this one. @uopeydel - I am curious about why dotnet watch was specified as the Dockerfile ENTRYPOINT. Can you explain your usage scenario? What is the purpose of this?

@uopeydel
Copy link
Author

uopeydel commented Sep 23, 2020

1 The query when have no ENV config is this one >
image
May be it because of @ it lost while generate query when have ENV config. It doesn't relate with data schema because of when I run it without ENV config it generate and run correctly.

2 @MichaelSimons Actually, I don't want to use it in docker container. I read many article no one use this way , I use pipeline create new image and deploy new one. But some of my customer require it because of they said they don't want to generate new docker image, image it to big size and they think if they change just one of parameter they don't want to re-generate new docker image. Then they decide to let me install git inside docker and replace new code and let it build again inside docker container (make it like VM ... ). They don't care if it rebuild and have downtime 15 - 20 second while rebuild. They use trigger with .yaml file when docker start first time it will execute .sh file in docker container. It will pull new one and replace code to code is in WORKDIR. If I build a code to .dll file. It not support to use dotnet watch run . And if I use .dll at ENTRYPOINT If I try to kill dotnet process by command kill $(ps aux | grep '<filename>.dll' | awk '{print $2}') for update code to new version (Just replace .dll file don't make it run new version of code) Docker will stop working and it going to loop > start container > run .sh file > repull code > kill .dll file > docker stop work > restart docker > run .sh file > loop. Then I use dotnet watch run.

@uopeydel
Copy link
Author

uopeydel commented Oct 1, 2020

Any idea? @carlossanlop @MichaelSimons

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants