Develop on Docker container from Intellij - docker

How can develop on my Docker container from Intellij? I am developing on macOS, but my development environment is inside a Docker container. In VSCode, I can use the Remote - Containers extension to open the files in my Docker container, go to function definitions, use the version of Go on the container, access the container shell--it's as if I am accessing a remote machine from VSCode. I didn't have to change my Dockerfile or mount any volumes. Everything just worked.
IntelliJ seems to have added something according to this, but the total functionality is unclear. I can attach to a running container using the Docker plugin, access the shell, and inspect the container's attributes, but none of the above other functionality with VSCode.
Here are some examples of why this is needed:
I am developing on macOS, but my target is specific to Intel Linux code. If I do Cmd+B on a symbol, I'm taken to a Darwin specific file
importing github.com/docker/libnetwork fails because the files in this package can only be built for Linux
The above doesn't happen on VSCode because I can develop directly on the container.

Related

VSCode cannot access Docker image inside wsl2 image

I am running a cuda enabled docker container inside wsl2 and when i try to use VSCode to run scripts inside it i cannot connect to it. The message in the docker plugin window is:
Error: connect EACCESS /var/run/docker.sock
I added the default user in the wsl to the docker group. I double-checked and i know for sure that i can run docker as a user. How do I elevate the VSCode privillages to make it able to access the docker inside the wsl image?
Btw. I cannot use docker desktop because it does not allow to use the gpu inside the container.
UPDATE
So with the set of plugins locally:Docker, Remote - WSL, Remote - Containers, Remote SSH, Remote Development, Remote SSH - editing configuration files
in the WSL: Docker Explorer, Docker, Docker Extension Pack
I am able to log from VSCode directly to the console and perform other basic operations (starting containers etc). Attaching VSCode is still impossible as for now. At least the menu option under RMB throws an error

VSCode in-container-debugging over SSH machine

I am trying to setup and advanced configuration with VScode insider and I ma facing an issue.
My setup is:
VSCode Running in my local machine Windows 10 with a Django source code hosted on my machine. I have no docker client on this machine, and I don't wont to install one...
A virtual machine with Ubuntu is running a docker daemon, docker client and docker-compose. My workspace is shared over vboxfs and mounted on my Ubuntu
A python docker container is running in the Ubuntu machine and running the mounted code.
I tried to use the Remote Extension to debug the python code inside the container. However, when a run my vscode inside on the remote SSH Taget (so the ubuntu machine), I am able to manage docker objects (images, containers, etc...) using the Docker extension of vscode, but I can't see the option: Remote-Containers: Open Folder in Container. It's not found in the F1 command... I can see the other related command like: Remote-Containers: Settings.
Do you have any idea ? Or my setup is not supported by the extension ? It seems like it supports SSH development or Container development but not mixing both together, right ?
Is there any other VSCode config to debug in my targeted setup ?
Regards

Do I still need to install Node.js or Python via docker container file when the OS is installed with python/node.js already?

I am trying to create the docker file (Image file) for the web application I am creating. Basically, the web application is written in Node.js and Vue.js. In order to create a docker container for the application, I have got the documentation from vue.js to create a docker file. The steps given are working file. I just wanted to clear my understanding in this part.
link:- https://cli.vuejs.org/guide/deployment.html#docker-nginx
If the necessary package Node/Python is installed in the OS (Not in the container), would the container be able to pick up the npm scripts and execute python scripts also? If yes, is it really dependent on the OS software packages as well?
Please help me with the understanding.
Yes, you need to install Node or Python or whatever software you need in your application in your container. The reason is that the container should be able to run on any host machine that has Docker installed, regardless of how the host machine is set up or what it software it has installed.
It might be a bit tedious at first to make sure that your Dockerfile installs all the software that is needed, but it becomes very useful when you want to run your container on another machine. Then all you have to do is type docker run and it should work!
Like David said above, Docker containers are isolated from your host machine and it should be treated as a completely different machine/host. The way containers can communicate with other containers or sometimes the host is through network ports.
One "exception" to the isolation between the container and the host is that the container can sometimes write to files in the host in order to persist data even after the container has been stopped. You can use volumes or mounts to allow containers to write to files on the host.
I would suggest the Docker Overview for more information about Docker.

Debugging a Go process in a container using Delve/Goland from the host

Before I burn hours trying it out I wanted to ask the community is this even possible?
Scenario:
Running Goland on host (may be any OS)
Running Go dev env in Alpine based container
Code on host volume mapped to container
Can I attach the Goland debugger (Delve) to a Go process in the container? I'm assuming I can run delve in the container headless and run the client on the host, punching whatever port is required? Will I have binary compatibility issues if the host is not linux?
I'd rather not duplicate the entire post in this answer, but have a look at this resource on how to use containers to run applications you write https://blog.jetbrains.com/go/2018/04/30/debugging-containerized-go-applications/
To answer this specifically, as long as you have Go, the application sources, and all dependencies installed on the host machine, you can develop in GoLand and then, using a mapped volume, you can also run it from the container.
However, this workflow sounds more like the workflow you'd normally have using VMs not containers, which is why in the above article all the running/debugging is done using the actual containers, rather than using bash inside a container to run those commands.

Can I wrap a custom desktop application in a docker container?

I would like to wrap a custom desktop application (don't have access to source code just the .exe and .msi) in a docker container from windows OS and share the image to my team to enable them access from windows OS. Could someone let me know if this is possible or please point me in the right direction (possibly a tutorial as I couldn't find it)?
No, Docker does not run Windows binaries. The Docker for Windows products run Linux inside of a VM as the Docker host and all containers are Linux based.

Resources