可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I have asp core api project and i am using visual studio 2017 to run my project.
After i renamed the docker container that was previously created using visual studio using this command on command line,
docker rename CONTAINER NEW_NAME
I receive the following message when i try to run the project again in visual studio.
Thanks for the help
Can not find docker container with the name starting with 'previous_container_name'.
回答1:
Delete the .vs
folder in your solution directory (close the solution first), the Docker image name seems to be cached somewhere in there.
回答2:
This error started happening to me when someone on the team unchecked the build checkbox for the docker-compose project. Make sure it is enabled in Build -> Configuration Manager
回答3:
I had a similar problem, and it was caused because I started Docker after opening the project. VS does some things with Docker on opening of the project, and will fail if Docker is not started.
Lesson learned: make sure Docker is running before starting Visual Studio. If Docker is not started, then start Docker, close your solution, and re-open it.
VS will re-create the container as it opens the project.
回答4:
This happened for me because I stopped a container manually via the commandline, then Visual Studio got confused.
To get round the issue I simply added a single ' ' space character to docker-compose.yml and saved the file. This forced Visual Studio to restart the container and connect to it.
I'm sure starting/stopping Visual Studio would also have worked, but the whitespace change was nice and fast.
回答5:
One more cause is using solution folders for your docker project and a version of Visual Studio 2017 less than 15.9, upgrading to 15.9+ fixed this for me, see this issue.
回答6:
In my case i have tried all of those but solution is very simple in V.S. 2019
Before all there is a bugfix packet for visual studio 2017 even if you using 19 beta, for this on https://visualstudio.microsoft.com/vs/
Download and install that pocket.
For automatically composing also you should add Docker Compose Support follow this link https://docs.microsoft.com/tr-tr/dotnet/standard/containerized-lifecycle-architecture/design-develop-containerized-apps/visual-studio-tools-for-docker
1-) Right click to targeted project root folder on solution explorer that contains Dockerfile and select add-> Docker Support it will ask you its always contains would you like to create new one? Click yes. It will create new Dockerfile.
You will see some changes in new Dockerfile like your project changes or nuget package changes affectness
2-) Right click the newly replaced Dockerfile and Build Image.
It will successfully build
3-) Choose debugger as Docker instead IIS Express vs. Even don't use other debugger while developing project if you do not need
回答7:
I also have the similar problem.
These steps always help me to solve the issues.
Solution 1:
1- Close VS
2- delete obj folder of root solution folder.
3- delete obj folder of all projects which are involved in docker-compose file.(example all APIs)
4- Open VS
5- Remove the docker-compose project from solution and add it again.
During the creation process, don't overwrite the old files with new ones, to prevent deletion of you current docker-compose.yml configuration.
Solution 2:
On the first time of container creation, copy the creation command:
example: docker-compose -f "[path]\docker-compose.yml" -f "[path]\docker-compose.override.yml" -f "[path]\docker-compose.vs.debug.g.yml" -p dockercompose17926074389345686639 --no-ansi up -d --no-build --force-recreate --remove-orphans
any time there is an error just run this command manually.
if anybody could find a constant solution please also let us know.