Can not find docker container

2020-07-16 02:16发布

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'.

7条回答
老娘就宠你
2楼-- · 2020-07-16 02:41

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.

查看更多
\"骚年 ilove
3楼-- · 2020-07-16 02:47

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.

查看更多
小情绪 Triste *
4楼-- · 2020-07-16 02:48

Delete the .vs folder in your solution directory (close the solution first), the Docker image name seems to be cached somewhere in there.

查看更多
Anthone
5楼-- · 2020-07-16 02:51

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

查看更多
我欲成王,谁敢阻挡
6楼-- · 2020-07-16 03:01

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.

查看更多
\"骚年 ilove
7楼-- · 2020-07-16 03:02

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

enter image description here

查看更多
登录 后发表回答