How to use minikube in VSCode devcontainer? - docker

I'm trying to use minikube inside a VSCode devcontainer to test my project. Althought I'm able to install minikube inside the container, minikube fails to start each time I lunch it.
After different type of configurations and different type of errors I'm starting to wondering if it make sense to use minikube inside a VSCode devcontainer. Anyone have already tried it? is there a correct way to run minikube inside a docker container?

Digging on the problem I've found the solution to my issue right on VSCode website. Here below the link to the GitHub repository:
https://github.com/Microsoft/vscode-dev-containers/tree/master/containers/kubernetes-helm

Related

Error when opening docker container in vscode in ubuntu

I am new to coding in containers using docker. I am trying to open a container inside vscode in order to work in the environment. However every time I open the container, it errors out of every time.
I am using vscode's docker extension to open the docker file in the cloned repository
After trying to launch the file in the container, it errors out and gives me this error code
I tried rebuilding the container to see if that would work, but it still gives me the same error.
I am really new to working on containers itself, so can anyone help me?

Testcontainers do not start after replacing Docker Desktop with minikube

I want to make my testcontainers in Java integration tests work with minikube replacing Docker Desktop.
I followed below article to get started:
https://www.atomicjar.com/2021/10/docker-on-windows-and-macos/#minikube
This is what I've got in testcontainers.properties
docker.client.strategy=org.testcontainers.dockerclient.EnvironmentAndSystemPropertyClientProviderStrategy
docker.host=tcp\://192.168.64.2\:2376
docker.cert.path=/Users/username/.minikube/certs
docker.tls.verify=true
Although my docker is up and running, I'm getting following exception:
Caused by: java.lang.IllegalStateException: Could not find a valid Docker environment. Please see logs and check configuration
Can anybody please suggest anything to make it working?
TA
If you are using gradle try -no-daemon flag to use a new daemon. Your old gradle daemon still using your previous testcontainers properties, also restart your IDE if you're running your build inside.
After restarting Minikube and Intellij editor, and updating testcontainer-bom to be the latest - from 1.15 to 1.16.2, I was able to pull some third-party docker images. This means docker is working now.
However, I'm still trying to find a way to work with local images (Other application docker images) for integration testing as it used to work with Docker Desktop.

Minikube restarts forever

I have an issue. I typed the minikube start command and it stuck. What should I do? Is deleting minikube the only solution?
Restarting existing docker container for "minikube"
You have provided too little information to conclusively solve your problem. But one way is to actually delete the minikube and restart. You can see this similar question. Make sure that you have proper privileges to run docker containers.
Generally, this problem occurs quite often on Ubuntu. You can find very extensive thread on github.
In addition to the Restarting existing docker container for "minikube", you should also get some other information (like specific error). If they are insufficient, you can always open an issue on github.
In the thread above you can find a couple of potential solutions. Here is one of them:
When I run minikube --start --driver=docker --alsologtostderr, I get the same error message with "no such file or directory".
Edit: I was able to fix this by changing to .deb docker instead of snap docker.
Per https://kubernetes.io/docs/tasks/tools/install-minikube/:
"If you're using the none driver in Debian or a derivative, use the .deb packages for Docker rather than the snap package, which does not work with Minikube. You can download .deb packages from Docker."
I did $ snap remove docker, then followed these instructions:
https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository
Maybe the error messages could be amended to tell this to the user?
You can try sudo minikube delete to delete the container first,
then minikube start and see if the issue is fixed or not.

Is it possible to mount docker container on VS code?

I saw it but I can't remember where I saw it.
It looked like seeing inside Linux, mounting the docker container on VS Code on Mac OS.
Is it possible to mount the docker container on VS code?
By "mount", I presume you're talking about opening VSCode inside the container instead of Docker volumes and bind mounts. You can install the Remote Containers extension to do this.
Also see the docs mentioned by #AttilaViniczai for how to create development containers/dev contianers for VSCode: https://code.visualstudio.com/docs/remote/create-dev-container
Install the VSCode extension
Select the Remote Explorer tab on the left side of VSCode and make sure you have Containers selected from the drop down menu.
Double click the container you want to work on and/or right click and select Attach to Container. This will attach VSCode to that Docker container and install its required tools inside automatically.
For more information about this, you can see the VSCode documentation here and a tutorial here.

Can we interact and troubleshoot containers inside kubernetes without command line access?

Can we interact and troubleshoot containers inside kubernetes without command line access? Or reading logs will be sufficient for debugging?
Is there any way for debugging the containers without command line (kubectl)?
Unfortunately the containers created FROM Scratch are not simple to debug, the best you can do is add logging and telemetry in the container so that you don't have to debug it. The other option is use minimal images like busybox.
The K8s team has a proposal for a a kubectl debug target-pod command, but is not something you can use yet.
In the worse scenarios you can try Scratch-debugger, it will create a busybox pod in the same node your pod being debuged is and call docker to inject the filesystem into the existing container.
You can set up access to the dashboard and make changes to the containers / read logs there.
https://kubernetes.io/docs/tasks/access-application-cluster/web-ui-dashboard/

Resources