Docker compose intellisense - docker

When creating docker-compose.yml vscode autocomplete/ intellisense doesn't work. Also ctrl+space doesn't work. How can I make it work ?

Currently you have to go back to a previous version of the Docker VSCode extension, such as v1.16.1 .
From the VSCode developers:
The functionality present in 1.17 for the language service is fairly limited; we're working on adding back a lot more in 1.18.
See https://github.com/microsoft/vscode-docker/issues/3222

Related

How to get started development inside docker container in windows operating system

I am a developer who is using Ubuntu 20.04 LTS regularly for my development. I never install any packages like, node, PHP, python in the OS and make use of docker for the purpose. VS Code is the editor I use, and the extension of the remote container will help me to develop & debug inside the docker container.
Right now, I am in the process of moving the development to a windows environment and I wanted to follow a similar workflow there too. Unfortunately, I am facing few issues like "file changes are not getting detected" (when npm serve in angular and react projects).
https://github.com/microsoft/WSL/issues/4739
https://www.reddit.com/r/bashonubuntuonwindows/comments/c48yej/wsl_2_react_not_reloading_with_file_changes/
I have tried different methods to solve the issue like
use wsl2 and then docker inside that and then serve from the container
use just docker and serve the code from inside the container
Regardless of the methods, the file changes are not getting detected inside the docker.
Trust me I have gone through many bizarre words like inotify, increasing the watchers, etc... Nothing helped.
Is there a developer out there following a similar practice in a Windows environment? (docker + windows)
Any help is highly appreciated.
I suggest moving the files to the wsl2 file system and not the windows.
Wsl2 'sees' the windows file system from inside a mount image /mnt/c .
Move out of it, like at ~ (cd ~) and i think your files will be normally watched .

How to compile a Flutter application on a docker container on Intellij Idea?

I have a full Docker image that has Flutter SDK, Android SDK, Dart SDK, etc, all installed and in the $PATH.
I made it work on Intellij Idea, I can click "deploy" and it launches, but then I don't know what else to do.
I thought Intellij Idea would work inside this container, and so it would find Dart SDK, etc, and work.
How can I compile my flutter project using the SDK from the container on Intellij Idea? And also how to use intellisense, etc, all from things inside the container
Seems like this is not something that is currently supported in IntelliJ, according to a forum-post answered by JetBrains staff.
How I see it, you have three options:
Switch to Visual Studio Code and follow these instructions
Use the in the forum-post mentioned Projector, which runs your IDE on a Server and you can connect to it using a web browser, or a Electron desktop client
Expose your SDKs from your Docker container and set the paths manually on your host system
With #3 I mean something like this, when running your container:
docker container run -itd \
-v /local/path/to/sdk:/docker/path/to/sdk \
devimage
and then in your IDE you can set the path to that, or you could even set some environment variables like e.g. ANDROID_HOME to point to the local bind location.
You may try this.
Go to File -> Project Structure
Set the path for Module, Library, Project, and SDK
Sometimes IntelliJ requires the PATH setup here.

I can't add docker contexts via VS Code because the button is missing. Why is this?

I am trying to create a Docker context with VS Code to enable me to deploy the container to Azure, following this microsoft tutorial.
The image shown in the tutorial has a button with a plus to create a new context, but my version does not have this button. I have the latest version of VS Code (1.55.0), the latest version of Docker (Docker version 19.03.13) and the Docker extension for VS Code, which has worked for every other step of this tutorial series and allowed me to stop and start containers as well as other features. I have tried this using Ubuntu 18.04.5 and 20.04.2, and followed the Linux instructions for installing Docker.
I am logged into Azure with VS Code and have deployed other things to Azure via VS Code, although I don't think that should make a difference.
Here is what I see in the context panel:
.
Here is what is shown in the tutorial:
.
Why don't I have the option to add a context through VS Code? How can I get it? Thanks.
It depends on VSCode's Keyboard Shotcuts. I can reproduce it:
You can set the Keyboard Shotcuts. Then the button will apear. Below is the steps:
Go to the View -> Command Palette, input the command docker context create like this:
Set the Keyboard Shotcuts, for example, here is my setting:
Then use the Keyboard Shotcuts, here it means click the Shift + Alt + C button, it shows like this:

docker support visual studio 2017 fails

I've been playing with docker for a while and was pleased to see the new tools in VS2017. I've had issues before with docker for windows but I can't see why this one is happening.
I create a webapp just straight from the box and add docker support. I then simply try and launch it with no changes and I get the following error.
I have checked that the container is registered and it does look to have gotten that far:
a quick docker ps -a yields this:
The thing is the error reporting appears to be trying to deploy from a build path does does indeed not exist (my projects are on my G drive not F, that is where visual studio is installed).
So what gives? I can run the docker-compose from the command line inside the project path and then docker-compose up and it seems fine. Seems visual studio is just using the incorrect path, not sure why.
Version in use are:
Docker for windows 17.04.0-ce-rc2-win6(10840)
Visual studio 2017: Version 15.1(26403.0)
I checked again which version of docker I was using and I was using from the edge stream. I fell back to stable and this issue went away.
I had the same problem. It turns out solution told above of reverting to Docker stable version solved it. With Edge version, the build looks for solution file in the VS IDE folder instead of current folder.

Build .NET Core Console Application into Docker

I created a new .NET Core Console Application with Visual Studio 2017 (RTM). Then added Docker support and got the docker file + compose files just fine. However there are few issues with them.
Docker compose files have version 2 which makes the build fail to the following error message
Microsoft.DotNet.Docker.CommandLineClientException: client version 1.22 is too old. Minimum supported API version is 1.24, please upgrade your client to a newer version.
This can be fixed by manually changing the compose file versions to 2.1. (not sure if valid fix) Then you'll get another error message
MSB4006 There is a circular dependency in the target dependency graph involving target "DockerCleanServiceReferences".
This I have no idea how to fix. I know the error message is due to some configuration that causes circular reference (e.g. post build event that does build)
So, any resources or tips how to package the .NET Core console application into docker container manually? I'm just getting to know Docker so don't assume I know anything of it yet.
Another question, that is there some place where I could get updated versions of these Visual Studio templates or are these known issues?
It turned out the problem for me was having my DockerFile, SLN file, and CSPROJ file all in the same folder. You know how when you create a solution, it asks you if you want to create a subdirectory? If you do not, and your SLN and CSPROJ files share the same folder, inevitably the Docker files will be added to this same folder, creating the circular reference. If your SLN file lives in the directory above your CSPROJ file, the DockerFile et al will be put into your parent directory with the SLN file, and all will be well. This solved it for me.
Can you please check if your Docker for Windows is targeting Linux? It's likely you were targeting Windows container, which is not supported with .NET Core yet.
On my first spin of VS2017 with docker, using the default template, I ran in to the same issue.
I referred to this article - https://blogs.msdn.microsoft.com/containerstuff/2017/03/13/visual-studio-2017-client-version-1-22-is-too-old/
This is what worked for me - As recommended, made this changes in docker-compose project's docker-compose.ci.build.yml :
The 'version' parameter on the top of the file which was set to 2, was change to 2.1
Repeated the same changes on the other files in the project including:
docker-compose.yml
docker-compose.override.yml
docker-compose.vs.debug.yml
docker-compose.vs.release.yml
Regarding your question on how to package a .NET Core console application into a Docker image manually. The https://github.com/dotnet/dotnet-docker-samples are intended to answer that very question. Check them out. If you run into issues with them or have suggestions please log an issue (https://github.com/dotnet/dotnet-docker-samples/issues).
Thanks for the post. We will be adding Nano Server container tooling "soon". Until then, you can work with Linux containers which will give a similar experience.

Resources